文章目录

  • 一、每日例会
  • 二、昨天已完成的工作
  • 三、今天计划完成的工作
  • 四、工作中遇到的困难
  • 五、项目燃尽图
  • 六、代码签入

一、每日例会

二、昨天已完成的工作

昨日已完成任务 第五篇Scrum冲刺博客</ a>

三、今天计划完成的工作

今日计划完成任务 棋盘样式,左边棋盘棋子的信息

四、工作中遇到的困难

五、项目燃尽图

六、代码签入

import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.BorderFactory;
public class GamePanel extends JPanel implements MouseListener,MouseMotionListener,ActionListener
{
private static final long serialVersionUID = 1353029267562430095L;

/** 游戏逻辑 */
private GameLogic gameLogic;/** 网格行数 */
final int gridRows = 10;/** 网格列数 */
final int gridColumns = 9;/** 网格尺寸 */
final int gridSize = 52;/** 网格宽度 */
final int gridsWidth = gridSize * (gridColumns - 1);/** 网格高度 */
final int gridsHeight = gridSize * (gridRows - 1);/** 网格左上角X坐标 */
final int gridsLeftX = 42;/** 网格左上角Y坐标 */
final int gridsTopY = 42;/** 象棋面板(要分层,否则棋盘标签压棋子标签) */
private JLayeredPane panelChess;/** 棋盘标签 */
JLabel labelChessBorad;/** 棋盘图片 */
private ImageIcon imageIconChessBoard;/** 棋盘状态信息(-1->无棋,其他数字->棋子信息数组的下标) */
int[][] chessBoradState = new int[gridRows][gridColumns];/** 棋子尺寸 */
final int chessSize = 44;/** 棋子标签 */
JLabel[] labelChess = new JLabel[32];/*** 棋子信息数组<br>* index -> 棋子索引<br>* color -> 棋子颜色(0-黑棋,255-红棋)<br>* type -> 棋子类型(rook、horse、elephant、guard、king、cannon、soldier)<br>* name -> 棋子名字(黑车、黑马、黑象、黑士、黑将、黑炮、黑卒、红兵、红炮、红车、红马、红相、红仕、红帅)<br>* number -> 棋子小标号(如卒1卒2中的1与2)<br>* direction -> 棋子方向(T-上方,B-下方)<br>* oldOldRow -> 棋子大上次行位置<br>* oldOldColumn -> 棋子大上次列位置<br>* oldRow -> 棋子上次行位置<br>* oldColumn -> 棋子上次列位置<br>* newRow -> 棋子本次行位置<br>* newColumn -> 棋子本次列位置<br>* dead -> 棋子是否处于死亡状态(T-死亡,F-活着)<br>* oldEatIndex -> 上次被其吃棋子下标<br>* eatIndex -> 本次被其吃棋子下标<br>*/
@SuppressWarnings("unchecked")   //数组不支持泛型Map<String,String>[] mapChess = new Map[32];/** 棋子图片 */
private ImageIcon[] imageIconChess = new ImageIcon[14];/** 红棋标识 */
final int REDCHESS = 255;/** 黑棋标识 */
final int BLACKCHESS = 0;/** 对战方式(0-人机对战,1-人人对战) */
int fightType ;/** 先手选择(1-玩家先手,2-电脑先手) */
int playFirst ;/** 红黑选择(255-玩家执红,0-玩家执黑) */
int chessColor ;/** 电脑棋子颜色 */
int computerChess = -1 ;/** 玩家棋子颜色 */
int playerChess = -1 ;/** 红棋悔棋数 */
int redUndoNum = 30;/** 黑棋悔棋数 */
int blackUndoNum = 30;/** 全部下棋信息 */
List<Map<String,String>> listChess = new ArrayList<Map<String,String>>();/** 移动线路图信息 */
List<Map<String,Integer>> listMove = new ArrayList<Map<String,Integer>>();/** 组合框控件 */
private JComboBox<String> jcb_fightType,jcb_playFirst,jcb_chessColor;/** 按钮控件 */
private JButton jb_new,jb_undo,jb_surrender;/** 标签控件 */
JLabel jlb_blackUndoText,jlb_blackStateText,jlb_redUndoText,jlb_redStateText;/** Logo图片 */
private ImageIcon imageIconLogo;/** 是否第一次点击 */
boolean isFirstClick = true;/** 第一次点击棋子 */
Map<String,String> firstClickChess = null;/*** 落子指示器<br>* row -> 行坐标<br>* column -> 列坐标<br>* show -> 是否显示(0-不显示,1-显示)<br>* color -> 颜色(0-黑,255-红)<br>*/
Map<String,Integer> mapPointerChess = new HashMap<String,Integer>();/*** 移动指示器<br>* row -> 行坐标<br>* column -> 列坐标<br>* show -> 是否显示(0-不显示,1-显示)<br>* color -> 颜色(-1-默认,0-黑,255-红)<br>*/
Map<String,Integer> mapPointerMove = new HashMap<String,Integer>();/** 判断游戏是否结束(true-结束,false-未结束) */
boolean isGameOver = true;/*** 功能:构造函数<br>*/
public GamePanel()
{//与主窗口大小保持一致,并设置背景色(去掉菜单高度)this.setSize(666,560);this.setLayout(null);//设置象棋面板this.panelChess = new JLayeredPane();this.panelChess.setBounds(0,0,504,558);this.panelChess.setLayout(null);this.add(this.panelChess);//加载图片this.loadImage();//设置棋盘背景图片this.labelChessBorad = new JLabel();this.labelChessBorad.setBounds(0,0,this.panelChess.getWidth(),this.panelChess.getHeight());this.labelChessBorad.setIcon(this.imageIconChessBoard);this.labelChessBorad.addMouseListener(this);this.labelChessBorad.addMouseMotionListener(this);this.panelChess.add(this.labelChessBorad,JLayeredPane.DEFAULT_LAYER);  //最底层//建立棋子标签this.createChess();//右边功能区布局this.option();//游戏逻辑this.gameLogic = new GameLogic(this);//初始化游戏this.initGame();
}/*** 功能:加载图片<br>* 备注:考虑Jar包问题,所以图片路径用URL格式<br>*/
private void loadImage()
{try{//棋盘图片this.imageIconChessBoard = new ImageIcon(new ImageIcon(this.getClass().getResource("/resource/chess/chessBoard.png")).getImage().getScaledInstance(this.panelChess.getWidth(),this.panelChess.getHeight(),Image.SCALE_SMOOTH));   //缩放图片来适应标签大小//棋子图片for(int i=0;i<this.imageIconChess.length;i++){this.imageIconChess[i] = new ImageIcon(new ImageIcon(this.getClass().getResource("/resource/chess/chess"+i+".png")).getImage().getScaledInstance(this.chessSize,this.chessSize,Image.SCALE_SMOOTH));  //缩放图片来适应标签大小}//Logo图片this.imageIconLogo = new ImageIcon(new ImageIcon(this.getClass().getResource("/resource/chess/logo.png")).getImage().getScaledInstance(100,50,Image.SCALE_SMOOTH));    //缩放图片来适应标签大小}catch(Exception e){e.printStackTrace();}
}/*** 功能:初始化游戏<br>*/
private void initGame()
{//重新设置参数this.isGameOver = true;//清空下棋与移动线路图列表this.listChess.clear();this.listMove.clear();//指示器初始化this.mapPointerChess.put("row",-1);this.mapPointerChess.put("column",-1);this.mapPointerChess.put("show",0);this.mapPointerChess.put("color",-1);this.mapPointerMove.put("row",-1);this.mapPointerMove.put("column",-1);this.mapPointerMove.put("show",0);this.mapPointerMove.put("color",-1);//对战方式if("人人对战".equals(this.jcb_fightType.getSelectedItem().toString())){this.fightType = 1;}else{this.fightType = 0;}//先手选择if("电脑先手".equals(this.jcb_playFirst.getSelectedItem().toString())){this.playFirst = 2;}else{this.playFirst = 1;}//红黑选择if("玩家执黑".equals(this.jcb_chessColor.getSelectedItem().toString())){this.chessColor = this.BLACKCHESS;}else{this.chessColor = this.REDCHESS;}//电脑与玩家棋子颜色if(this.fightType == 0){if(this.chessColor == this.BLACKCHESS){this.playerChess = this.BLACKCHESS;this.computerChess = this.REDCHESS;}else{this.playerChess = this.REDCHESS;this.computerChess = this.BLACKCHESS;}}//悔棋数初始化this.redUndoNum = 30;this.blackUndoNum = 30;//设置控件状态this.setComponentState(false);//初始化棋子(默认我方棋子在下方)this.initChess();
}/*** 功能:布局棋子<br>*/
private void initChess()
{//先按默认设置棋子信息(玩家执红:红方在下,黑方在上)for(int index=0;index<this.mapChess.length;index++){this.mapChess[index].put("index",Integer.toString(index));this.mapChess[index].put("oldOldRow","-1");this.mapChess[index].put("oldOldColumn","-1");this.mapChess[index].put("oldRow","-1");this.mapChess[index].put("oldColumn","-1");this.mapChess[index].put("dead","F");this.mapChess[index].put("oldEatIndex","-1");this.mapChess[index].put("eatIndex","-1");if(index < 9)         //黑车马象士将士象马车{this.mapChess[index].put("direction","T"); //上方this.mapChess[index].put("newRow","0");this.mapChess[index].put("newColumn",Integer.toString(index));}else if(index == 9)       //黑炮1{this.mapChess[index].put("direction","T");this.mapChess[index].put("newRow","2");this.mapChess[index].put("newColumn","1");}else if(index == 10)    //黑炮2{this.mapChess[index].put("direction","T");this.mapChess[index].put("newRow","2");this.mapChess[index].put("newColumn","7");}else if(index > 10 && index < 16)   //黑卒n{this.mapChess[index].put("direction","T");this.mapChess[index].put("newRow","3");this.mapChess[index].put("newColumn",Integer.toString(2 * index - 22));}else if(index >= 16 && index < 21)  //红兵n{this.mapChess[index].put("direction","B");    //下方this.mapChess[index].put("newRow","6");this.mapChess[index].put("newColumn",Integer.toString(2 * index - 32));}else if(index == 21)     //红炮1{this.mapChess[index].put("direction","B");this.mapChess[index].put("newRow","7");this.mapChess[index].put("newColumn","1");}else if(index == 22)        //红炮2{this.mapChess[index].put("direction","B");this.mapChess[index].put("newRow","7");this.mapChess[index].put("newColumn","7");}else if(index > 22 && index < 32)   //红车马相仕帅仕相马车{this.mapChess[index].put("direction","B");this.mapChess[index].put("newRow","9");this.mapChess[index].put("newColumn",Integer.toString(index - 23));}}//如果玩家执黑则坐标反过来if(this.chessColor == this.BLACKCHESS){//棋子信息对调(行变abs(9-行),列不变)for(int index=0;index<this.mapChess.length;index++){int row = Integer.parseInt(this.mapChess[index].get("newRow"));this.mapChess[index].put("newRow",Integer.toString(Math.abs(9 - row)));if("T".equals(this.mapChess[index].get("direction"))){this.mapChess[index].put("direction","B");}else{this.mapChess[index].put("direction","T");}}}//清空棋盘状态信息for(int row=0;row<this.chessBoradState.length;row++){for(int column=0;column<this.chessBoradState[0].length;column++){this.chessBoradState[row][column] = -1;}}//再根据棋子状态信息设置棋盘状态信息for(int index=0;index<this.mapChess.length;index++){int row = Integer.parseInt(this.mapChess[index].get("newRow"));int column = Integer.parseInt(this.mapChess[index].get("newColumn"));this.chessBoradState[row][column] = index;}//重新布局棋子(X->列,Y->行)for(int index=0;index<this.mapChess.length;index++){int row = Integer.parseInt(this.mapChess[index].get("newRow"));int column = Integer.parseInt(this.mapChess[index].get("newColumn"));this.labelChess[index].setBounds(this.gridsLeftX + column * this.gridSize - this.chessSize/2,this.gridsTopY + row * this.gridSize  - this.chessSize/2,this.chessSize,this.chessSize);}}/*** 功能:设置控件状态<br>* 参数:true-新开局;false-未开局<br>*/
public void setComponentState(boolean _flag)
{if(_flag)  //新游戏已经开始了{this.jcb_fightType.setEnabled(false);this.jcb_playFirst.setEnabled(false);this.jcb_chessColor.setEnabled(false);this.jb_new.setEnabled(false);this.jb_undo.setEnabled(true);this.jb_surrender.setEnabled(true);}else //新游戏还未开始{this.jcb_fightType.setEnabled(true);this.jcb_playFirst.setEnabled(true);this.jcb_chessColor.setEnabled(true);this.jb_new.setEnabled(true);this.jb_undo.setEnabled(false);this.jb_surrender.setEnabled(false);}
}/*** 功能:建立棋子标签<br>*/
private void createChess()
{for(int index=0;index<this.labelChess.length;index++){this.labelChess[index] = new JLabel();this.labelChess[index].setName(Integer.toString(index));this.mapChess[index] = new HashMap<String,String>();if(index == 0)         //黑车1{this.labelChess[index].setIcon(this.imageIconChess[4]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","rook");this.mapChess[index].put("name","黑车");this.mapChess[index].put("number","1");}else if(index == 8)      //黑车2{this.labelChess[index].setIcon(this.imageIconChess[4]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","rook");this.mapChess[index].put("name","黑车");this.mapChess[index].put("number","2");}else if(index == 1)      //黑马1{this.labelChess[index].setIcon(this.imageIconChess[3]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","horse");this.mapChess[index].put("name","黑马");this.mapChess[index].put("number","1");}else if(index == 7)     //黑马2{this.labelChess[index].setIcon(this.imageIconChess[3]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","horse");this.mapChess[index].put("name","黑马");this.mapChess[index].put("number","2");}else if(index == 2)     //黑象1{this.labelChess[index].setIcon(this.imageIconChess[2]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","elephant");this.mapChess[index].put("name","黑象");this.mapChess[index].put("number","1");}else if(index == 6)      //黑象2{this.labelChess[index].setIcon(this.imageIconChess[2]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","elephant");this.mapChess[index].put("name","黑象");this.mapChess[index].put("number","2");}else if(index == 3)      //黑士1{this.labelChess[index].setIcon(this.imageIconChess[1]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","guard");this.mapChess[index].put("name","黑士");this.mapChess[index].put("number","1");}else if(index == 5)     //黑士2{this.labelChess[index].setIcon(this.imageIconChess[1]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","guard");this.mapChess[index].put("name","黑士");this.mapChess[index].put("number","2");}else if(index == 4)     //黑将{this.labelChess[index].setIcon(this.imageIconChess[0]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","king");this.mapChess[index].put("name","黑将");this.mapChess[index].put("number","");}else if(index == 9 || index == 10)       //黑炮n{this.labelChess[index].setIcon(this.imageIconChess[5]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","cannon");this.mapChess[index].put("name","黑炮");this.mapChess[index].put("number",Integer.toString(index - 8));}else if(index > 10 && index < 16)    //黑卒n{this.labelChess[index].setIcon(this.imageIconChess[6]);this.mapChess[index].put("color","0");this.mapChess[index].put("type","soldier");this.mapChess[index].put("name","黑卒");this.mapChess[index].put("number",Integer.toString(index - 10));}else if(index >= 16 && index < 21)    //红兵n{this.labelChess[index].setIcon(this.imageIconChess[13]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","soldier");this.mapChess[index].put("name","红兵");this.mapChess[index].put("number",Integer.toString(index - 15));}else if(index == 21 || index == 22)       //红炮n{this.labelChess[index].setIcon(this.imageIconChess[12]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","cannon");this.mapChess[index].put("name","红炮");this.mapChess[index].put("number",Integer.toString(index - 20));}else if(index == 23)     //红车1{this.labelChess[index].setIcon(this.imageIconChess[11]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","rook");this.mapChess[index].put("name","红车");this.mapChess[index].put("number","1");}else if(index == 31)      //红车2{this.labelChess[index].setIcon(this.imageIconChess[11]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","rook");this.mapChess[index].put("name","红车");this.mapChess[index].put("number","2");}else if(index == 24)      //红马1{this.labelChess[index].setIcon(this.imageIconChess[10]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","horse");this.mapChess[index].put("name","红马");this.mapChess[index].put("number","1");}else if(index == 30)     //红马2{this.labelChess[index].setIcon(this.imageIconChess[10]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","horse");this.mapChess[index].put("name","红马");this.mapChess[index].put("number","2");}else if(index == 25)     //红相1{this.labelChess[index].setIcon(this.imageIconChess[9]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","elephant");this.mapChess[index].put("name","红相");this.mapChess[index].put("number","1");}else if(index == 29)       //红相2{this.labelChess[index].setIcon(this.imageIconChess[9]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","elephant");this.mapChess[index].put("name","红相");this.mapChess[index].put("number","2");}else if(index == 26)       //红仕1{this.labelChess[index].setIcon(this.imageIconChess[8]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","guard");this.mapChess[index].put("name","红仕");this.mapChess[index].put("number","1");}else if(index == 28)      //红仕2{this.labelChess[index].setIcon(this.imageIconChess[8]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","guard");this.mapChess[index].put("name","红仕");this.mapChess[index].put("number","2");}else if(index == 27)      //红帅{this.labelChess[index].setIcon(this.imageIconChess[7]);this.mapChess[index].put("color","255");this.mapChess[index].put("type","king");this.mapChess[index].put("name","红帅");this.mapChess[index].put("number","");}this.labelChess[index].addMouseListener(this);this.labelChess[index].addMouseMotionListener(this);this.panelChess.add(this.labelChess[index],JLayeredPane.DRAG_LAYER); //最高层}}

第 6 篇 Scrum 冲刺博客相关推荐

  1. Beta阶段——第4篇 Scrum 冲刺博客

    Beta阶段--第4篇 Scrum 冲刺博客 标签:软件工程 一.站立式会议照片 二.每个人的工作 (有work item 的ID) 昨日已完成的工作 人员 工作 林羽晴 昨日完成获取提醒语句的接口函 ...

  2. Beta阶段——第3篇 Scrum 冲刺博客

    Beta阶段--第3篇 Scrum 冲刺博客 标签:软件工程 一.站立式会议照片 二.每个人的工作 (有work item 的ID) 昨日已完成的工作 人员 工作 林羽晴 完成了报表数据的接口函数 顾 ...

  3. Beta阶段——第2篇 Scrum 冲刺博客

    Beta阶段--第2篇 Scrum 冲刺博客 标签:软件工程 一.站立式会议照片 二.每个人的工作 (有work item 的ID) 昨日已完成的工作 人员 工作 林羽晴 完成https安全连接的问题 ...

  4. Beta阶段——第5篇 Scrum 冲刺博客

    Beta阶段--第5篇 Scrum 冲刺博客 标签:软件工程 一.站立式会议照片 二.每个人的工作 (有work item 的ID) 昨日已完成的工作 人员 工作 林羽晴 完成了邮箱发送功能的测试,测 ...

  5. Beta阶段——第6篇 Scrum 冲刺博客

    Beta阶段--第6篇 Scrum 冲刺博客 标签:软件工程 一.站立式会议照片 二.每个人的工作 (有work item 的ID) 昨日已完成的工作 人员 工作 林羽晴 完成了函数的编写,提供报表数 ...

  6. 第 1 篇 Scrum 冲刺博客

    ① 今日各个成员的任务安排 陆大岳.彭霖:实现服务器,编写代码, 胡智韬:编写和优化图标 牛浩远:编写第一篇博客 •今天完成的任务 陆大岳彭霖:实现云服务器 参考了IMplementist大神的自己动 ...

  7. Alpha阶段敏捷冲刺①Scrum 冲刺博客

    第 1 篇 Scrum 冲刺博客对整个冲刺阶段起到领航作用,应该主要包含三个部分的内容: 各个成员在 Alpha 阶段认领的任务 成员 任务 张晨晨 完成界面设计(前端) 黄登峰 完成界面设计(前端) ...

  8. Scrum 冲刺博客集合

    Day1 博客链接:http://www.cnblogs.com/coolgirls/p/8869839.html Day2 博客链接:http://www.cnblogs.com/coolgirls ...

  9. Scrum 冲刺博客第二篇

    一.当天站立式会议照片一张 二.每个人的工作 (有work item 的ID),并将其记录在码云项目管理中 昨天已完成的工作 配置和连接微信小程序服务器 个人界面设计 部主页界面设计 答题界面设计 今 ...

最新文章

  1. 浅谈APP的分享功能,有时候社交裂变形式比内容更“重要”
  2. c++中的左移、右移运算
  3. Effective Java之避免创建不必要的对象(五)
  4. sql月度分组_SQL Server按月分组
  5. mysql如何让表建立连接吗_MySQL 表与表之间建立关系
  6. uiautomator +python 安卓UI自动化尝试
  7. php获取当地时间 time zone
  8. android系统性能优化---(9)Android 绿色应用公约
  9. exif.js html图片旋转,exif.js 实现图片旋转到正常
  10. knewone最新分享购物网站模板
  11. Java常用JSON库FastJson,Gson,Jackson,Json-lib性能及特点比较,常用工具方法
  12. linux定时任务Crond之服务器同步时间05
  13. java put请求_计算机毕业设计中用java实现小程序推送(springboot实现)
  14. 学生时代的经历,利用Python在机房杀红蜘蛛,脱离老师控制!
  15. 【新手教程】51Sim-One Cloud 2.0 创建你的第一个案例
  16. 统一身份认证与授权标准介绍:OpenID,OAuth2,SAML
  17. pod install 时遇到 Automatically assigning platform `iOS` with version `11.0` on target XXX......
  18. 软件设计师-备考知识点总结
  19. 《淘宝规则》创建店铺的规则与实施细则
  20. linux光盘读取不良,程序员偷偷深爱的9个不良编程习惯

热门文章

  1. Linux 安装 docker,使用docker 安装mysql、redis、jdk、nginx
  2. java计算机毕业设计网络游戏管理网站源码+数据库+系统+lw文档+mybatis+运行部署
  3. 外省市公积金转入南京
  4. java 卡表_jvm-卡表,垃圾回收时的重要手段
  5. 光波导的概念及平面介质光波导中光的传播
  6. 计算机ping不通格式,如何解决 ping 不通 127.0.0.1
  7. 浅谈医疗信息化安全的防御体系
  8. 如何锁定计算机硬盘e盘,手把手教你如何给硬盘加密
  9. stm32f103rct6使用内部晶振作为时钟源
  10. ISE - ChipScope 使用教程