-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from anlingyi/release
1.6.4-beta
- Loading branch information
Showing
61 changed files
with
3,512 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
xechat-commons/src/main/java/cn/xeblog/commons/entity/game/chess/ChessDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cn.xeblog.commons.entity.game.chess; | ||
|
||
import cn.xeblog.commons.entity.game.GameDTO; | ||
import lombok.*; | ||
|
||
/** | ||
* @author anlingyi | ||
* @date 2020/6/5 | ||
*/ | ||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ChessDTO extends GameDTO { | ||
|
||
private int x; | ||
private int y; | ||
|
||
/** 对战方式:1-红棋 2-黑棋 */ | ||
private int type; | ||
|
||
/** 棋子索引 */ | ||
private int index; | ||
|
||
/** 选项 */ | ||
Option option = Option.DEFAULT; | ||
|
||
/** 当前界面 用途:后期可设置我方和对方不同界面 */ | ||
public UI currentUI = UI.CLASSIC; | ||
|
||
public enum Option { | ||
SURRENDER, UNDO, GAME_OVER, CHECK, DEFAULT | ||
} | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum UI { | ||
CLASSIC("经典模式", 1) | ||
// , FISH("摸鱼模式", 0) | ||
|
||
; | ||
|
||
private String name; | ||
|
||
private int value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
xechat-plugin/src/main/java/cn/xeblog/plugin/game/box/PushBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package cn.xeblog.plugin.game.box; | ||
|
||
import cn.hutool.core.util.StrUtil; | ||
import cn.xeblog.commons.enums.Game; | ||
import cn.xeblog.plugin.annotation.DoGame; | ||
import cn.xeblog.plugin.game.AbstractGame; | ||
import cn.xeblog.plugin.game.box.util.ImagesUtils; | ||
import cn.xeblog.plugin.game.box.util.MapsUtils; | ||
import com.intellij.openapi.ui.ComboBox; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.*; | ||
|
||
/** | ||
* 功能描述: 数独主方法 D:\代码工程\project\test | ||
* | ||
* @author ☆程序员鼓励师☆ | ||
* @date 2022年8月20日01:02:27 | ||
*/ | ||
@DoGame(Game.PUSH_BOX) | ||
public class PushBox extends AbstractGame { | ||
|
||
private int level; | ||
private boolean init; | ||
private PushBoxUI pushBoxUI; | ||
|
||
@Override | ||
protected void start() { | ||
initMainPanel(); | ||
mainPanel.setLayout(new BorderLayout()); | ||
mainPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH); | ||
mainPanel.add(Box.createHorizontalStrut(10), BorderLayout.EAST); | ||
|
||
if (!init && pushBoxUI != null) { | ||
level = pushBoxUI.getLevel(); | ||
} | ||
pushBoxUI = new PushBoxUI(level); | ||
mainPanel.add(pushBoxUI, BorderLayout.CENTER); | ||
mainPanel.add(getBottomPanel(), BorderLayout.SOUTH); | ||
|
||
mainPanel.setMinimumSize(new Dimension(pushBoxUI.getTheWidth() + 40, pushBoxUI.getTheHeight() + 50)); | ||
mainPanel.updateUI(); | ||
|
||
pushBoxUI.requestFocusInWindow(); | ||
init = false; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
// 初始化图片 | ||
ImagesUtils.initMapDataDefault(); | ||
// 初始化地图 | ||
MapsUtils.initMapDataDefault(); | ||
// 是否初始化 | ||
init = true; | ||
level = 1; | ||
|
||
initMainPanel(); | ||
|
||
mainPanel.setMinimumSize(new Dimension(150, 300)); | ||
JPanel menuJPanel = new JPanel(); | ||
menuJPanel.setBounds(10, 10, 100, 330); | ||
mainPanel.add(menuJPanel); | ||
|
||
JLabel title = new JLabel("推箱子"); | ||
title.setFont(new Font("", Font.BOLD, 14)); | ||
menuJPanel.add(title); | ||
|
||
Box vBox = Box.createVerticalBox(); | ||
menuJPanel.add(vBox); | ||
|
||
Dimension selectDimension = new Dimension(30, 30); | ||
|
||
vBox.add(Box.createVerticalStrut(20)); | ||
JLabel levelLabel = new JLabel("关卡选择:"); | ||
levelLabel.setFont(new Font("", Font.BOLD, 13)); | ||
vBox.add(levelLabel); | ||
vBox.add(Box.createVerticalStrut(5)); | ||
|
||
ComboBox<String> gameLevelBox = getComboBox(selectDimension); | ||
gameLevelBox.addActionListener(l -> level = gameLevelBox.getSelectedIndex() + 1); | ||
vBox.add(gameLevelBox); | ||
|
||
vBox.add(Box.createVerticalStrut(10)); | ||
vBox.add(getStartJButton("开始游戏")); | ||
vBox.add(getTipsButton()); | ||
vBox.add(getExitButton()); | ||
|
||
mainPanel.updateUI(); | ||
} | ||
|
||
// 创建按钮面板 | ||
private JPanel getBottomPanel() { | ||
JPanel jPanel = new JPanel(); | ||
jPanel.add(getStartJButton("重置本关")); | ||
jPanel.add(getMenuJButton()); | ||
return jPanel; | ||
} | ||
|
||
public JButton getMenuJButton() { | ||
JButton menu = new JButton("主菜单"); | ||
menu.addActionListener(e -> init()); | ||
return menu; | ||
} | ||
|
||
public JButton getTipsButton() { | ||
JButton tips = new JButton("按键提示"); | ||
tips.addMouseListener(new MouseAdapter() { | ||
@Override | ||
public void mouseClicked(MouseEvent e) { | ||
String message = "↑ ↓ ← → 方向键控制人物移动方向<br>"; | ||
switch (e.getButton()) { | ||
case 1: | ||
message += "DELETE:撤销/上一步<br>祝你玩得愉快!"; | ||
break; | ||
case 2: | ||
message += "DELETE:撤销/上一步<br>隐藏技能都被你发现了!真棒!<br>PAGE UP:上一关<br>PAGE DOWN:下一关<br>"; | ||
break; | ||
default: | ||
break; | ||
} | ||
message = StrUtil.format("<html><body>{}<body></html>", message); | ||
JOptionPane.showMessageDialog(null, message, "按键提示", JOptionPane.INFORMATION_MESSAGE); | ||
} | ||
}); | ||
|
||
return tips; | ||
} | ||
|
||
public JButton getStartJButton(String title) { | ||
JButton another = new JButton(title); | ||
another.addActionListener(e -> start()); | ||
return another; | ||
} | ||
|
||
public ComboBox<String> getComboBox(Dimension dimension) { | ||
ComboBox<String> comboBox = new ComboBox<>(); | ||
comboBox.setPreferredSize(dimension); | ||
for (int i = 1; i <= MapsUtils.getTotal(); i++) { | ||
comboBox.addItem(StrUtil.format("第{}关", i)); | ||
} | ||
comboBox.setSelectedItem(StrUtil.format("第{}关", level)); | ||
return comboBox; | ||
} | ||
} |
Oops, something went wrong.