• R/O
  • SSH
  • HTTPS

chaplet: 提交


Commit MetaInfo

修訂34 (tree)
時間2007-07-05 21:10:52
作者koe

Log Message

プロットから手札に戻すアクションを実装

Change Summary

差異

--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/NovaServerPlugin.java (revision 33)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/NovaServerPlugin.java (revision 34)
@@ -9,7 +9,6 @@
99
1010 import jp.sf.chaplet.StorageUtils;
1111 import jp.sf.chaplet.core.server.ClientProxy;
12-import jp.sf.chaplet.core.server.ServerAction;
1312 import jp.sf.chaplet.core.server.ServerPlugin;
1413 import jp.sf.chaplet.core.server.User;
1514 import jp.sf.chaplet.nova.NovaConfig;
@@ -56,41 +55,22 @@
5655 * @see jp.sf.chaplet.core.server.ServerPlugin#init()
5756 */
5857 public void init() throws Exception {
59-// tarotManager.setFileName(ConfigLoader.getInstance().getWorkDir() +
60-// System.getProperty("file.separator") + tarotManager.getFileName());
61- ServerAction[] actions = new ServerAction[14];
62- actions[0] = new LoginServerAction();
63- actions[1] = new LogoutServerAction();
64- actions[2] = new FeedAction();
65- actions[3] = new HandToPileAction();
66- actions[4] = new AddCharacterAction();
67- actions[5] = new PlotToPileAction();
68- actions[6] = new ReactionAction();
69- actions[7] = new RemoveCharacterAction();
70- actions[8] = new SceneAction();
71- actions[9] = new ToPlotAction();
72- actions[10] = new YamabikiAction();
73- actions[11] = new GiveCardAction();
74- actions[12] = new ExchangePlotAction();
75- actions[13] = new InitializeAction();
76- for (int i = 0; i < actions.length; i++) {
77- actions[i].init(server, this);
78- }
79- addAction("login", actions[0]);
80- addAction("logout", actions[1]);
81- addAction("nova:feed", actions[2]);
82- addAction("nova:handtopile", actions[3]);
83- addAction("nova:addchara", actions[4]);
84- addAction("nova:plottopile", actions[5]);
85- addAction("nova:reaction", actions[6]);
86- addAction("nova:delchara", actions[7]);
87- addAction("nova:scene", actions[8]);
88- addAction("nova:toplot", actions[9]);
89- addAction("nova:yamabiki", actions[10]);
90- addAction("nova:givecard", actions[11]);
91- addAction("nova:exchange", actions[12]);
92- addAction("nova:init", actions[13]);
93- addAction("nova:status", actions[0]);
58+ LoginServerAction loginAction = new LoginServerAction();
59+ addAction("login", loginAction);
60+ addAction("nova:status", loginAction);
61+ addAction("logout", new LogoutServerAction());
62+ addAction("nova:feed", new FeedAction());
63+ addAction("nova:handtopile", new HandToPileAction());
64+ addAction("nova:addchara", new AddCharacterAction());
65+ addAction("nova:plottopile", new PlotToPileAction());
66+ addAction("nova:reaction", new ReactionAction());
67+ addAction("nova:delchara", new RemoveCharacterAction());
68+ addAction("nova:scene", new SceneAction());
69+ addAction("nova:toplot", new ToPlotAction());
70+ addAction("nova:yamabiki", new YamabikiAction());
71+ addAction("nova:givecard", new GiveCardAction());
72+ addAction("nova:tohand", new PlotToHandAction());
73+ addAction("nova:init", new InitializeAction());
9474
9575 NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class);
9676 tarotManager.setConfig(config);
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/PlotToHandAction.java (nonexistent)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/PlotToHandAction.java (revision 34)
@@ -0,0 +1,43 @@
1+/**
2+ *
3+ */
4+package jp.sf.chaplet.nova.server;
5+
6+import java.io.IOException;
7+
8+import jp.sf.chaplet.ActionResult;
9+import jp.sf.chaplet.core.server.ClientProxy;
10+import jp.sf.chaplet.core.server.ServerAction;
11+
12+/**
13+ * PlotToHandAction。<br>
14+ * <ol>
15+ * <li> nova:tohand
16+ * <li> [プロット番号]
17+ * <li> カード
18+ * </ol>
19+ * @version $Id$
20+ */
21+public class PlotToHandAction extends ServerAction {
22+
23+ /**
24+ * @see jp.sf.chaplet.core.server.ServerAction#execute(java.lang.String[], jp.sf.chaplet.core.server.ClientProxy)
25+ */
26+ @Override
27+ public ActionResult execute(String[] request, ClientProxy proxy) throws IOException {
28+ int plotNo = Integer.parseInt(request[1]);
29+ String card = request[2];
30+ NovaServerPlugin plugin = (NovaServerPlugin) getPlugin();
31+ Hand hand = plugin.getHandManager().getHandOf(proxy.getSessionId());
32+ hand.removeCard(plotNo, card);
33+ hand.addCard(0, card);
34+ String[] resp = new String[3];
35+ resp[0] = "ok/" + request[0];
36+ resp[1] = request[1];
37+ resp[2] = request[2];
38+ proxy.sendMessage(resp);
39+ sendStatus();
40+ return ActionResult.OK_NEXT;
41+ }
42+
43+}
Added: svn:keywords
## -0,0 +1 ##
+" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/HandToPileAction.java (revision 33)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/HandToPileAction.java (revision 34)
@@ -25,7 +25,7 @@
2525 throws IOException {
2626 Hand hand = ((NovaServerPlugin)getPlugin()).getHandManager().getHandOf(proxy.getSessionId());
2727 hand.removeCard(0, request[1]);
28- if(request.length == 2 || !request[2].equals("hidden")){
28+ if((request.length == 2 || !request[2].equals("hidden")) && hand.getCardCount(0) < 4){
2929 hand.addCard(0, ((NovaServerPlugin)getPlugin()).getCardManager().next());
3030 }
3131 String[] cards = hand.getHand(0);
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/INovaView.java (revision 33)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/INovaView.java (revision 34)
@@ -19,8 +19,15 @@
1919 */
2020 public abstract void addPlot(final int plotNo, final String[] prot);
2121
22- public abstract void moveToPlot(final int plotNo, final String card);
22+ public abstract void moveToPlot(final int plotNo, final String card);
2323
24+ /**
25+ * プロットから手札にカードを移動する。
26+ * @param plotNo 異動元のプロット番号
27+ * @param card カード
28+ */
29+ public abstract void moveToHand(final int plotNo, final String card);
30+
2431 /**
2532 * プロットからカードを捨てる。
2633 * @param plotNo プロット番号
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/NovaView.java (revision 33)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/NovaView.java (revision 34)
@@ -122,7 +122,7 @@
122122 gridBagConstraints.weightx = 5.0;
123123 gridBagConstraints.weighty = 1.0;
124124 gridBagConstraints.gridx = 0;
125- this.setSize(355, 322);
125+ this.setSize(355, 360);
126126 this.setLayout(new GridBagLayout());
127127 this.add(getJScrollPane(), gridBagConstraints);
128128 this.add(getButtonPanel(), gridBagConstraints1);
@@ -422,7 +422,7 @@
422422 toHandButton.setText("△手札へ");
423423 toHandButton.addActionListener(new java.awt.event.ActionListener() {
424424 public void actionPerformed(java.awt.event.ActionEvent e) {
425- System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
425+ actionMap.get("plotToHand").actionPerformed(e);
426426 }
427427 });
428428 }
@@ -826,4 +826,17 @@
826826 }
827827 });
828828 }
829+
830+ /**
831+ * @see jp.sf.chaplet.nova.ui.INovaView#moveToHand(int, java.lang.String)
832+ */
833+ public void moveToHand(final int plotNo, final String cardS) {
834+ SwingUtilities.invokeLater(new Runnable() {
835+ public void run() {
836+ Card card = new Card(cardS);
837+ getPlotTableModel().remove(plotNo, card);
838+ getCardListModel().addElement(card);
839+ }
840+ });
841+ }
829842 } // @jve:decl-index=0:visual-constraint="10,10"
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/client/NovaClientPlugin.java (revision 33)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/client/NovaClientPlugin.java (revision 34)
@@ -8,7 +8,6 @@
88
99 import javax.swing.JPanel;
1010
11-import jp.sf.chaplet.core.client.ClientAction;
1211 import jp.sf.chaplet.core.client.ClientPlugin;
1312 import jp.sf.chaplet.core.ui.IPluginView;
1413 import jp.sf.chaplet.core.ui.IPrefView;
@@ -35,34 +34,18 @@
3534 */
3635 @Override
3736 protected void startup() {
38- ClientAction[] actions = new ClientAction[12];
39- actions[0] = new AddCharacterAction();
40- actions[1] = new FeedAction();
41- actions[2] = new HandToPileAction();
42- actions[3] = new PlotToPileAction();
43- actions[4] = new ReactionAction();
44- actions[5] = new RemoveCharacterAction();
45- actions[6] = new SceneAction();
46- actions[7] = new ToPlotAction();
47- actions[8] = new YamabikiAction();
48- actions[9] = new SetStatusAction();
49- actions[10] = new GiveCardAction();
50- actions[11] = new ExchangePlotAction();
51- for (int i = 0; i < actions.length; i++) {
52- actions[i].init(getController(), this);
53- }
54- addAction("nova:addchara", actions[0]);
55- addAction("nova:feed", actions[1]);
56- addAction("nova:handtopile", actions[2]);
57- addAction("nova:plottopile", actions[3]);
58- addAction("nova:reaction", actions[4]);
59- addAction("nova:delchara", actions[5]);
60- addAction("nova:scene", actions[6]);
61- addAction("nova:toplot", actions[7]);
62- addAction("nova:yamabiki", actions[8]);
63- addAction("nova:status", actions[9]);
64- addAction("nova:givecard", actions[10]);
65- addAction("nova:exchange", actions[10]);
37+ addAction("nova:addchara", new AddCharacterAction());
38+ addAction("nova:feed", new FeedAction());
39+ addAction("nova:handtopile", new HandToPileAction());
40+ addAction("nova:plottopile", new PlotToPileAction());
41+ addAction("nova:reaction", new ReactionAction());
42+ addAction("nova:delchara", new RemoveCharacterAction());
43+ addAction("nova:scene", new SceneAction());
44+ addAction("nova:toplot", new ToPlotAction());
45+ addAction("nova:yamabiki", new YamabikiAction());
46+ addAction("nova:status", new SetStatusAction());
47+ addAction("nova:givecard", new GiveCardAction());
48+ addAction("nova:tohand", new PlotToHandAction());
6649
6750 view = new NovaView();
6851 view.setController(this);
@@ -184,6 +167,28 @@
184167 getConnection().sendMessage(message);
185168 }
186169 }
170+
171+ @Action
172+ public void plotToHand(){
173+ int rowIndex = view.getPlotTable().getSelectedRow();
174+ if(rowIndex < 0){
175+ rowIndex = 0;
176+ }
177+ if(view.getPlotTable().getRowCount() < rowIndex){
178+ return;
179+ }
180+ PlotChara chara = view.getPlotTableModel().indexOf(rowIndex);
181+
182+ int columnIndex = view.getPlotTable().getSelectedColumn();
183+ if(columnIndex <= 0){
184+ return;
185+ }
186+ Plot plot = view.getPlotTableModel().getPlot(chara.getCharaNo(), columnIndex - 1);
187+ if(plot != null){
188+ String[] message= new String[]{"nova:tohand", String.valueOf(chara.getCharaNo()), plot.getCard().toString()};
189+ getConnection().sendMessage(message);
190+ }
191+ }
187192
188193 /**
189194 * プロットのカードをリアクション宣言する、またはリアクション宣言したカードを元に戻す。
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/client/YamabikiAction.java (revision 33)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/client/YamabikiAction.java (revision 34)
@@ -19,7 +19,7 @@
1919 */
2020 public ActionResult messageRecieved(String[] message) {
2121 appendFunctionLog("カード機能", message[1],
22- "山引き " + NovaUtil.toVisibleStyle(message[2]));
22+ NovaUtil.toVisibleStyle(message[2]) + " (山引き)");
2323 return ActionResult.OK_NEXT;
2424 }
2525 }
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/client/PlotToHandAction.java (nonexistent)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/client/PlotToHandAction.java (revision 34)
@@ -0,0 +1,28 @@
1+/**
2+ *
3+ */
4+package jp.sf.chaplet.nova.client;
5+
6+import jp.sf.chaplet.ActionResult;
7+import jp.sf.chaplet.core.client.ClientAction;
8+
9+/**
10+ * PlotToHandAction<br>
11+ * <ol>
12+ * <li> ok/nova:tohand
13+ * <li> [プロット番号]
14+ * <li> カード
15+ * </ol>
16+ * @version $Id$
17+ */
18+public class PlotToHandAction extends ClientAction {
19+ /**
20+ * @see jp.sf.chaplet.core.client.ClientAction#responseRecieved(java.lang.String[])
21+ */
22+ @Override
23+ public ActionResult responseRecieved(String[] response) {
24+ NovaClientPlugin plugin = (NovaClientPlugin) getPlugin();
25+ plugin.getNovaView().moveToHand(Integer.parseInt(response[1]), response[2]);
26+ return ActionResult.OK_NEXT;
27+ }
28+}
Added: svn:keywords
## -0,0 +1 ##
+" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/core/jp/sf/chaplet/core/server/ChatServer.java (revision 33)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/server/ChatServer.java (revision 34)
@@ -64,6 +64,7 @@
6464 public ChatServer(String masterName){
6565 owner = masterName;
6666 userManager.setMasterId(masterName);
67+ server = this;
6768 }
6869
6970 /**
--- chaplet/trunk/src/core/jp/sf/chaplet/core/server/ServerPlugin.java (revision 33)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/server/ServerPlugin.java (revision 34)
@@ -66,6 +66,7 @@
6666 * @param action アクション
6767 */
6868 protected void addAction(String name, ServerAction action){
69+ action.init(server, this);
6970 actionMap.put(name, action);
7071 }
7172
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/ChatClient.java (revision 33)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/ChatClient.java (revision 34)
@@ -183,7 +183,15 @@
183183 }
184184
185185 /**
186+ * @see jp.sf.chaplet.core.client.ClientPlugin#getController()
186187 */
188+ @Override
189+ public ChatClient getController() {
190+ return this;
191+ }
192+
193+ /**
194+ */
187195 private void init() throws IOException {
188196 ApplicationContext context = ApplicationContext.getInstance();
189197 for (Plugin plugin : ConfigLoader.getInstance().load().getPlugins()) {
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/ClientPlugin.java (revision 33)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/ClientPlugin.java (revision 34)
@@ -63,6 +63,7 @@
6363 * @param action アクション
6464 */
6565 protected void addAction(String name, ClientAction action) {
66+ action.init(getController(), this);
6667 actionMap.put(name, action);
6768 }
6869
Show on old repository browser