Team programming blog (Card Game)

Team situation

member Task Assignment Team members blog
Chun Mei Business Type design, logic design, game operation codes No Leader
Pan Xu Master Card and state, music, animation No Crew
Yanggeng Chen Warrior cards and state, css table No Crew

No reference to other projects

Gitee part

https://gitee.com/suyuan37/java_card_game

Submit records:

https://gitee.com/suyuan37/java_card_game/commits/master

Preliminary investigation

Game total planning and design reference from the legendary [Hearthstone] [] [killing minaret full moon] three games to kill the minaret of the main class of type Reference

Function Chart

Object Oriented Design

Package diagram:

uml (only show key category):

Project run shot

  1. log in

  1. main menu

  1. My cards

  1. Production team

  1. Combat interface

  1. Obtain booty


Key Code Project

Games start module (battlefield)

  1. Cards: cards to get out of the view, whether or not to meet the licensing requirements to meet the effect caused by the cards and move the card hand card

    public void play() {
         if (selectedIndex != -1) {
             Card card = myself.getHandCardList().get(selectedIndex);
             textArea.appendText("you use card: "+ card.nameProperty().getValue() +"\n" +card.effect(enemy, myself) + "\n\n");
    
             boolean canUse = myself.use(card, enemy);
             if(canUse == false)
             {
                 textArea.appendText("short of sp\nyou can't use the card\n\n");
                 return ;
             }
             myself.getHandCardList().remove(selectedIndex);
             showUsedCard(card);
             showHandCard();
             showStatus();
             selectedIndex = -1;
             // myHP.setText(myself.getHealthPower()+" ");
             if(Integer.parseInt(enemy.getHealthPower())<=0)
             {
                 isWin = true;
                 showResult();
             }
         } else {
             textArea.appendText("please choose a card\n");
         }
    
     }
  2. End Round: Round implementation of the enemy after the end of round after round of execution enemy back to their bout

    public void finish() {
         playCardImage.setImage(null);
         isYourTurn = false;
         turnLabel.setText("enemy turn");
         enemy.settleStatus();
         showStatus();
         if(enemy.getCardLibrary().isEmpty()) enemy.freshCardLibrary(enemyTempLibrary);
         if(myself.getCardLibrary().isEmpty()) myself.freshCardLibrary(myTempLibrary);
         enemy.getTurnCard();
         while (true) {
             if(!enemy.isActionable()) 
             {
                 break;
             }
             Card card = ai.getNextCard();
             if (card == null)
                 break;
             textArea.appendText("enemy use card: "+ card.nameProperty().getValue() +"\n" +card.effect(enemy, myself) + "\n\n");
             enemy.use(card, myself);
             showStatus();
    
             if(Integer.parseInt(myself.getHealthPower()) <= 0)
             {
                 isWin = false;
                 showResult();
                 return ;
             }
         }
         isYourTurn = true;
         myself.settleStatus();
         turnLabel.setText("Your turn");
         boolean getEnoughCard = myself.getTurnCard();
         if (!getEnoughCard)
             myself.freshCardLibrary(myTempLibrary);
         showHandCard();
         showStatus();
         if(!myself.isActionable())
         {
    
             playButton.setDisable(true);
         }
         else
         {
             playButton.setDisable(false);
         }
    
     }
  3. Game starts (initialization): Heavy and wash their opponent's library, access to the first round of the hand, to start the game

    public void gameStart() {
    
         myself.freshCardLibrary(myTempLibrary);
         showStatus();
         myself.getHandCard(5);
         ai = new EasyAI(enemy, myself);
         ai.initialize();
         showHandCard();
         turnLabel.setText("Your turn");
     }

Cards and status module

Cards and status of class (Card, Status), were made to meet the needs of different design features of the game

public abstract boolean use(Creature myself, Creature enemy);
public abstract String effect(Creature myself,Creature enemy);

use the method used to achieve the effect of each card, effect method to obtain the effect caused by the String cards, there is a TextArea used to store each such String in the battle screen, as the combat log

public abstract void addStatus(Creature myself,Creature enemy);
public abstract void settle(Creature myself);

addStatus method used to achieve added each state, settle the method used to achieve the status settlement, the beginning of each round starts on all states to conduct a settlement of the status bar, to achieve the corresponding effect

Animation

Animation is currently only implements a fade effect, the effect on the case using the cards, kill, using animation and other add landscaping

public class Fade {
    
    private FadeTransition ft;
    public Fade(Node node)
    {
        FadeTransition ft = new FadeTransition(Duration.millis(1000), node);
        this.ft = ft;
    }
    
    public void fadeFrom()
    {
        ft.setFromValue(1.0);
        ft.setToValue(0.0);
        ft.setAutoReverse(false);
        ft.play();
    }
    public void fadeTo()
    {
        ft.setFromValue(0.0);
        ft.setToValue(1.0);
        ft.setAutoReverse(false);
        ft.play();
    }
}

Code scan results

After scanning the code, we get a lot of the wrong problem, after many hours of modification, and finally completed the required modifications

Improvement and feelings

  1. For this class-based, though it looks a hurry, but each member of the group, the object-oriented design capabilities have a good upgrade for this part javafx from scratch also made great progress.
  2. 课设时间太少,虽然是提前布置的,但是前期的时间被其他课目占用,并没有足够的时间准备,对于javafx的动画方面仅仅只是做了最基本的使用。
  3. 为卡牌设计出牌动画
  4. 完善AI算法
  5. 单纯为单机游戏,未使用数据库,未能实现多人功能

Guess you like

Origin www.cnblogs.com/suyuan333/p/12174361.html