}
}
- public Message send(String txt)
+ public Message send(String dst, String txt)
{
if (txt == null || txt.length() == 0)
return null;
if (this.validate() != State.READY)
return null;
- Message msg = new Message(this.channel, this.name, txt);
+ Message msg = new Message(dst, this.name, txt);
if (msg.type == Message.Type.JOIN)
this.channel = msg.msg;
this.raw(msg.line);
return msg;
}
+ public Message send(String txt)
+ {
+ return this.send(this.channel, txt);
+ }
+
public Message recv()
{
while (true) try {
public Task task;
public Cards cards;
public String admin;
+ public boolean looked;
/* Static methods */
private static String[] getCards(String msg, String regex)
return;
String txt = msg.txt;
+ if (txt.matches(".*turn!.*") && !this.looked) {
+ this.send(this.admin, ".look");
+ this.looked = true;
+ }
if (txt.startsWith("You have: ")) {
this.cards.hand = Spades.getCards(txt, "You have: (.*)");
this.cards.requestRender();
}
/* UI Callbacks */
+ public boolean onConnect()
+ {
+ Os.debug("Spades: onConnect");
+ this.looked = false;
+ this.send(this.admin, ".status");
+ this.send(this.admin, ".turn");
+ return true;
+ }
+
public boolean onBid(int bid)
{
Os.debug("Spades: onBid - " + bid);
public boolean onPass(String card)
{
Os.debug("Spades: onPass - " + card);
- return this.send(".pass " + card);
+ return this.send(this.admin, ".pass " + card);
}
public boolean onLook()
}
/* Helper functions */
+ private boolean send(String dst, String msg)
+ {
+ if (this.task == null)
+ return false;
+ this.task.send(dst, msg);
+ return true;
+ }
private boolean send(String msg)
{
if (this.task == null)
}
/* Public methods */
+ public Message send(String dst, String txt)
+ {
+ if (this.client == null)
+ return null;
+ Message msg = this.client.send(dst, txt);
+ if (msg != null)
+ this.command(MESSAGE, msg);
+ return msg;
+ }
+
public Message send(String txt)
{
if (this.client == null)