From 8b24f730e6c8d05694d67ef79cc277dd4cba4281 Mon Sep 17 00:00:00 2001 From: alik1378 Date: Sun, 7 Jul 2019 01:04:15 +0430 Subject: [PATCH] custom spellcard debug --- src/Controller/Server.java | 13 ++++++++++--- src/View/Viewer.java | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Controller/Server.java b/src/Controller/Server.java index 1df6b8e..54c4f29 100644 --- a/src/Controller/Server.java +++ b/src/Controller/Server.java @@ -640,9 +640,11 @@ else if (currentGame.getManaOfPlayers()[currentGame.getTurn()] < ((Unit) card).g currentGame.increaseCountOfFlagsInFlagsCollecting(); ((Unit)card).setHasFlag(true); ((Unit)card).addFlag(currentCell.getItems().get(i)); + currentCell.getItems().remove(currentCell.getItems().get(i)); } if(currentCell.getItems().get(i).isCollectAble()){ currentGame.addCollectableItems(currentCell.getItems().get(i)); + currentCell.getItems().remove(currentCell.getItems().get(i)); } } currentCell.setItems(null); @@ -746,9 +748,10 @@ public void createCustomUnit(String name, int type, Target target, int AP, int H ((Unit)card).setSpecialPowerCoolDown(specialPowerCoolDown); CardBuilder.createJsonFileFromTheObject(card); } - public Spell createCustomSpell(boolean stun, boolean disarm, boolean poison, int weakness, boolean fire, int attackChange, + public Spell createCustomSpell(String name, boolean stun, boolean disarm, boolean poison, int weakness, boolean fire, int attackChange, int HPChanger, boolean holyBuff, boolean deBuff, int attack, int changeMana, int rounds, boolean positive){ Spell spell = new Spell(); + spell.setName(name); spell.setStun(stun); spell.setDisarm(disarm); spell.setPoison(poison); @@ -764,10 +767,14 @@ public Spell createCustomSpell(boolean stun, boolean disarm, boolean poison, int spell.setPositive(positive); return spell; } - public void createCustomSpellCard(Spell spell, Target target, int manacost){ + public void createCustomSpellCard(Spell spell, Target target, int cost, int manaCost, String desc){ SpellCard card = new SpellCard(); + card.setName(spell.getName()); + spell.setName(null); card.setSpell(spell); - card.setManaCost(manacost); + card.setPrice(cost); + card.setDescription(desc); + card.setManaCost(manaCost); card.setTarget(target); CardBuilder.createJsonFileFromTheObject(card); } diff --git a/src/View/Viewer.java b/src/View/Viewer.java index b766f96..8260c4e 100644 --- a/src/View/Viewer.java +++ b/src/View/Viewer.java @@ -314,6 +314,16 @@ public void graphicShowCustomCard(){ positive.relocate(230,620); positive.setStyle("-fx-min-width: 105px;-fx-border-style: solid;-fx-border-width: 1px;-fx-border-color: #666;-fx-max-width: 105px;-fx-min-height: 37px;-fx-font-weight: bold;-fx-background-color: rgba(0,0,0,1);-fx-text-fill: white"); + TextField manaCost = new TextField(); + manaCost.setPromptText("manaCost"); + manaCost.relocate(390,220); + manaCost.setStyle("-fx-min-width: 105px;-fx-border-style: solid;-fx-border-width: 1px;-fx-border-color: #666;-fx-max-width: 105px;-fx-min-height: 37px;-fx-font-weight: bold;-fx-background-color: rgba(0,0,0,1);-fx-text-fill: white"); + + TextField desc = new TextField(); + desc.setPromptText("desc"); + desc.relocate(390,260); + desc.setStyle("-fx-min-width: 105px;-fx-border-style: solid;-fx-border-width: 1px;-fx-border-color: #666;-fx-max-width: 105px;-fx-min-height: 37px;-fx-font-weight: bold;-fx-background-color: rgba(0,0,0,1);-fx-text-fill: white"); + @@ -331,7 +341,7 @@ public void graphicShowCustomCard(){ createCustomCardBtn.setOnMouseClicked(mouseEvent -> { try { Target target = controller.createTarget(targetNum.getText(), targetGP.getText(), targetType.getText()); - Spell customSpell = controller.createCustomSpell(Boolean.parseBoolean(stun.getText()), Boolean.parseBoolean(disarm.getText()), + Spell customSpell = controller.createCustomSpell(name.getText(),Boolean.parseBoolean(stun.getText()), Boolean.parseBoolean(disarm.getText()), Boolean.parseBoolean(poison.getText()), Integer.parseInt(weaknes.getText()), Boolean.parseBoolean(fire.getText()), Integer.parseInt(attackChange.getText()), Integer.parseInt(HPChanger.getText()), Boolean.parseBoolean(holyBuff.getText()), Boolean.parseBoolean(deBuff.getText()), Integer.parseInt(attack.getText()), Integer.parseInt(changeMana.getText()), @@ -341,7 +351,7 @@ public void graphicShowCustomCard(){ Integer.parseInt(HP.getText()), attackType.getText(), Integer.parseInt(range.getText()) , customSpell, specialPowerCastTime.getText(), Integer.parseInt(specialPowerCoolDown.getText()), Integer.parseInt(cost.getText())); else if (custom.getText().toLowerCase().equals("spell")) - controller.createCustomSpellCard(customSpell, target, Integer.parseInt(cost.getText())); + controller.createCustomSpellCard(customSpell, target, Integer.parseInt(cost.getText()), Integer.parseInt(manaCost.getText()), desc.getText()); }catch (Exception e){ System.out.println("fill the form correctly!!!"); } @@ -358,7 +368,7 @@ else if (custom.getText().toLowerCase().equals("spell")) imageView.setPreserveRatio(true); group.getChildren().addAll(imageView,back,name,type,targetType,targetGP,AP,HP,attackType,range,specialPowerCastTime, specialPowerCoolDown,cost,createCustomCardBtn,spell,stun,disarm,poison,weaknes, fire, attackChange, - HPChanger,custom,holyBuff,deBuff,attack,changeMana,rounds,positive,targetNum); + HPChanger,custom,holyBuff,deBuff,attack,changeMana,rounds,positive,targetNum, manaCost, desc); } catch (Exception e){ System.err.println("Error While Showing Custom Card !");