]> Pileus Git - ~andy/spades/blob - src/org/pileus/spades/Spades.java
Add Spades class and tie things together
[~andy/spades] / src / org / pileus / spades / Spades.java
1 package org.pileus.spades;
2
3 public class Spades
4 {
5         /* Private data */
6         public Task  task;
7         public Cards cards;
8
9         /* Widget callback functions */
10         public Spades()
11         {
12         }
13
14         /* IRC Callbacks */
15         public void onMessage(Message msg)
16         {
17                 Os.debug("Spades: onMessage");
18         }
19
20         /* UI Callbacks */
21         public boolean onBid(int bid)
22         {
23                 Os.debug("Spades: onBid - " + bid);
24                 return this.send(".bid " + bid);
25         }
26
27         public boolean onPass(String card)
28         {
29                 Os.debug("Spades: onPass - " + card);
30                 return this.send(".pass " + card);
31         }
32
33         public boolean onLook()
34         {
35                 Os.debug("Spades: onLook");
36                 return this.send(".look");
37         }
38
39         public boolean onPlay(String card)
40         {
41                 Os.debug("Spades: onPlay - " + card);
42                 return this.send(".play " + card);
43         }
44
45         public boolean onTurn()
46         {
47                 Os.debug("Spades: onTurn");
48                 return this.send(".turn");
49         }
50
51         /* Helper functions */
52         private boolean send(String msg)
53         {
54                 if (this.task == null)
55                         return false;
56                 this.task.send(msg);
57                 return true;
58         }
59 }