DealerRegisterPlan.java

package jadex.examples.blackjack.dealer;

import jadex.adapter.fipa.*;
import jadex.examples.blackjack.*;
import jadex.examples.blackjack.player.strategies.*;
import jadex.runtime.IMessageEvent;
import jadex.runtime.Plan;

/**
* Plan to handle join request of a player.
*/
public class DealerRegisterPlayerPlan extends Plan
{
/**
* Plan body.
*/
public void body()
{
IMessageEvent request = (IMessageEvent)getInitialEvent();

// the player should have sent its name, account-status and its strategy-name
// the message-content should look like this: 'join:name:strategy:account:color'
RequestJoin rj = (RequestJoin)request.getContent();
Player player = rj.getPlayer();
player.setAgentID((AgentIdentifier)request.getParameter("sender").getValue());
getLogger().info("New player "+player);
if(!getBeliefbase().getBeliefSet("players").containsFact(player))
{
getBeliefbase().getBeliefSet("players").addFact(player);
player.setState(Player.STATE_IDLE);
}
else
{
// Reset entry.
Player old = (Player)getBeliefbase().getBeliefSet("players").getFact(player);
old.setState(Player.STATE_IDLE);
}

// set FIPA-performative for the message sent back to the player
// the content of the answer is just the games standard timeout.
rj.setTimeout(((Long)getBeliefbase().getBelief("playerwaitmillis").getFact()).intValue());
Done done = new Done(rj);
sendMessage(request.createReply("inform_action_done", done));
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值