mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Merge pull request #1212 from Card-Forge/autoHealWhenEnteringTowns
Auto heal when entering towns
This commit is contained in:
@@ -16,10 +16,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Clipboard;
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import forge.adventure.scene.ForgeScene;
|
||||
import forge.adventure.scene.GameScene;
|
||||
import forge.adventure.scene.Scene;
|
||||
import forge.adventure.scene.SceneType;
|
||||
import forge.adventure.scene.*;
|
||||
import forge.adventure.stage.MapStage;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.animation.ForgeAnimation;
|
||||
@@ -52,10 +49,7 @@ import forge.toolbox.*;
|
||||
import forge.util.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class Forge implements ApplicationListener {
|
||||
public static final String CURRENT_VERSION = "1.6.53.001";
|
||||
@@ -404,13 +398,13 @@ public class Forge implements ApplicationListener {
|
||||
if (GuiBase.isAndroid())
|
||||
return;
|
||||
if (isMobileAdventureMode) {
|
||||
if (cursorA0 != null && name == "0") {
|
||||
if (cursorA0 != null && Objects.equals(name, "0")) {
|
||||
setGdxCursor(cursorA0);
|
||||
return;
|
||||
} else if (cursorA1 != null && name == "1") {
|
||||
} else if (cursorA1 != null && Objects.equals(name, "1")) {
|
||||
setGdxCursor(cursorA1);
|
||||
return;
|
||||
} else if (cursorA2 != null && name == "2") {
|
||||
} else if (cursorA2 != null && Objects.equals(name, "2")) {
|
||||
setGdxCursor(cursorA2);
|
||||
return;
|
||||
}
|
||||
@@ -974,7 +968,6 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
}
|
||||
/** Retrieve assets.
|
||||
* @param other if set to true returns otherAssets otherwise returns cardAssets
|
||||
*/
|
||||
public static Assets getAssets() {
|
||||
return ((Forge)Gdx.app.getApplicationListener()).assets;
|
||||
@@ -990,6 +983,7 @@ public class Forge implements ApplicationListener {
|
||||
if (newScene instanceof GameScene)
|
||||
MapStage.getInstance().clearIsInMap();
|
||||
currentScene = newScene;
|
||||
|
||||
currentScene.enter();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -425,13 +425,33 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
o.run();
|
||||
}
|
||||
|
||||
public void heal(int amount) {
|
||||
life = Math.min(life + amount, maxLife);
|
||||
onLifeTotalChangeList.emit();
|
||||
public boolean fullHeal() {
|
||||
if (life < maxLife) {
|
||||
life = Math.max(maxLife, life);
|
||||
onLifeTotalChangeList.emit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void fullHeal() {
|
||||
life = maxLife;
|
||||
public void potionOfFalseLife() {
|
||||
if (gold >= falseLifeCost() && life == maxLife) {
|
||||
life = maxLife + 2;
|
||||
gold -= falseLifeCost();
|
||||
onLifeTotalChangeList.emit();
|
||||
onGoldChangeList.emit();
|
||||
} else {
|
||||
System.out.println("Can't afford cost of false life " + falseLifeCost());
|
||||
System.out.println("Only has this much gold " + gold);
|
||||
}
|
||||
}
|
||||
|
||||
public int falseLifeCost() {
|
||||
return 200 + (int)(50 * getStatistic().winLossRatio());
|
||||
}
|
||||
|
||||
public void heal(int amount) {
|
||||
life = Math.min(life + amount, maxLife);
|
||||
onLifeTotalChangeList.emit();
|
||||
}
|
||||
public void defeated() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import forge.Forge;
|
||||
import forge.adventure.stage.GameHUD;
|
||||
@@ -11,7 +12,8 @@ import forge.adventure.util.Current;
|
||||
* Scene for the Inn in towns
|
||||
*/
|
||||
public class InnScene extends UIScene {
|
||||
TextButton heal, sell, leave;
|
||||
TextButton tempHitPointCost, sell, leave;
|
||||
Label tempHitPoints;
|
||||
Image healIcon, sellIcon, leaveIcon;
|
||||
|
||||
public InnScene() {
|
||||
@@ -23,8 +25,8 @@ public class InnScene extends UIScene {
|
||||
Forge.switchToLast();
|
||||
}
|
||||
|
||||
public void heal() {
|
||||
Current.player().fullHeal();
|
||||
public void potionOfFalseLife() {
|
||||
Current.player().potionOfFalseLife();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,10 +43,10 @@ public class InnScene extends UIScene {
|
||||
InnScene.this.done();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("heal", new Runnable() {
|
||||
ui.onButtonPress("tempHitPointCost", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InnScene.this.heal();
|
||||
InnScene.this.potionOfFalseLife();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("sell", new Runnable() {
|
||||
@@ -57,13 +59,26 @@ public class InnScene extends UIScene {
|
||||
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||
sell = ui.findActor("sell");
|
||||
sell.getLabel().setText(Forge.getLocalizer().getMessage("lblSell"));
|
||||
heal = ui.findActor("heal");
|
||||
heal.getLabel().setText(Forge.getLocalizer().getMessage("lblHeal"));
|
||||
|
||||
tempHitPoints = ui.findActor("tempHitPoints");
|
||||
tempHitPoints.setText(Forge.getLocalizer().getMessageorUseDefault("lblTempHitPoints", "Temporary Hit Points"));
|
||||
|
||||
leaveIcon = ui.findActor("leaveIcon");
|
||||
healIcon = ui.findActor("healIcon");
|
||||
sellIcon = ui.findActor("sellIcon");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
|
||||
int tempHealthCost = Current.player().falseLifeCost();
|
||||
boolean purchaseable = Current.player().getMaxLife() == Current.player().getLife() &&
|
||||
tempHealthCost <= Current.player().getGold();
|
||||
|
||||
tempHitPointCost = ui.findActor("tempHitPointCost");
|
||||
tempHitPointCost.setDisabled(!purchaseable);
|
||||
tempHitPointCost.getLabel().setText("$" + tempHealthCost);
|
||||
}
|
||||
|
||||
private void sell() {
|
||||
|
||||
@@ -8,8 +8,11 @@ import forge.adventure.pointofintrest.PointOfInterest;
|
||||
import forge.adventure.stage.MapStage;
|
||||
import forge.adventure.stage.PointOfInterestMapRenderer;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Current;
|
||||
import forge.adventure.util.TemplateTmxMapLoader;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import forge.sound.SoundEffectType;
|
||||
import forge.sound.SoundSystem;
|
||||
|
||||
/**
|
||||
* Scene that will render tiled maps.
|
||||
@@ -19,6 +22,7 @@ public class TileMapScene extends HudScene {
|
||||
TiledMap map;
|
||||
PointOfInterestMapRenderer tiledMapRenderer;
|
||||
private String nextMap;
|
||||
private boolean autoheal = false;
|
||||
private float cameraWidth = 0f, cameraHeight = 0f;
|
||||
|
||||
public TileMapScene() {
|
||||
@@ -46,6 +50,10 @@ public class TileMapScene extends HudScene {
|
||||
}
|
||||
stage.act(Gdx.graphics.getDeltaTime());
|
||||
hud.act(Gdx.graphics.getDeltaTime());
|
||||
if (autoheal) { //todo add simple bg animation or effect
|
||||
SoundSystem.instance.play(SoundEffectType.Enchantment, false);
|
||||
autoheal = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +88,11 @@ public class TileMapScene extends HudScene {
|
||||
@Override
|
||||
public void enter() {
|
||||
super.enter();
|
||||
if (inTown()) {
|
||||
// auto heal
|
||||
if (Current.player().fullHeal())
|
||||
autoheal = true; // to play sound/effect on act
|
||||
}
|
||||
}
|
||||
|
||||
public void load(PointOfInterest point) {
|
||||
|
||||
@@ -236,7 +236,16 @@ public class GameHUD extends Stage {
|
||||
miniMapPlayer.setPosition(miniMap.getX() + xPosMini - miniMapPlayer.getWidth()/2, miniMap.getY() + yPosMini - miniMapPlayer.getHeight()/2);
|
||||
if (GuiBase.isAndroid()) // prevent drawing on top of console
|
||||
miniMapPlayer.setVisible(!console.isVisible()&&miniMap.isVisible());
|
||||
|
||||
//colored lifepoints
|
||||
if (Current.player().getLife() >= Current.player().getMaxLife()) {
|
||||
//color green if max life
|
||||
lifePoints.setColor(Color.GREEN);
|
||||
} else if (Current.player().getLife() <= 5) {
|
||||
//color red if critical
|
||||
lifePoints.setColor(Color.RED);
|
||||
} else {
|
||||
lifePoints.setColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
Texture miniMapTexture;
|
||||
|
||||
@@ -20,13 +20,22 @@
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"name": "heal",
|
||||
"text": "Heal",
|
||||
"name": "tempHitPointCost",
|
||||
"text": "Cost",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"x": 60,
|
||||
"y": 200
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "tempHitPoints",
|
||||
"font": "default",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"x": 60,
|
||||
"y": 180
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "sellIcon",
|
||||
|
||||
@@ -20,13 +20,22 @@
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"name": "heal",
|
||||
"text": "Heal",
|
||||
"name": "tempHitPointCost",
|
||||
"text": "Cost",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"x": 165,
|
||||
"y": 105
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"name": "tempHitPoints",
|
||||
"font": "default",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"x": 165,
|
||||
"y": 85
|
||||
},
|
||||
{
|
||||
"type": "Image",
|
||||
"name": "sellIcon",
|
||||
|
||||
@@ -2897,3 +2897,4 @@ lblWinProper=Sieg
|
||||
lblLossProper=Niederlage
|
||||
lblWinLossRatio=Sieg/Niederlage-Quote
|
||||
lblHeal=Heilen
|
||||
lblTempHitPoints=Temporäre Trefferpunkte
|
||||
|
||||
@@ -2899,4 +2899,5 @@ lblEdit=Edit
|
||||
lblWinProper=Win
|
||||
lblLossProper=Loss
|
||||
lblWinLossRatio=Win Loss Ratio
|
||||
lblHeal=Heal
|
||||
lblHeal=Heal
|
||||
lblTempHitPoints=Temporary Hit Points
|
||||
@@ -2899,4 +2899,5 @@ lblEdit=Editar
|
||||
lblWinProper=Ganar
|
||||
lblLossProper=Pérdida
|
||||
lblWinLossRatio=Relación de pérdidas
|
||||
lblHeal=Curar
|
||||
lblHeal=Curar
|
||||
lblTempHitPoints=Puntos de golpe temporales
|
||||
|
||||
@@ -2903,3 +2903,4 @@ lblWinProper=Vincita
|
||||
lblLossProper=Perdita
|
||||
lblWinLossRatio=Rapporto per perdite vincenti
|
||||
lblHeal=Guarire
|
||||
lblTempHitPoints=Punti ferita temporanei
|
||||
|
||||
@@ -2899,3 +2899,4 @@ lblWinProper=勝つ
|
||||
lblLossProper=損失
|
||||
lblWinLossRatio=損失率を獲得しました
|
||||
lblHeal=癒し
|
||||
lblTempHitPoints=一時的なヒットポイント
|
||||
|
||||
@@ -2989,3 +2989,4 @@ lblWinProper=Vitória
|
||||
lblLossProper=Derrota
|
||||
lblWinLossRatio=Taxa de Vitória Derrota
|
||||
lblHeal=Curar
|
||||
lblTempHitPoints=Pontos de vida temporários
|
||||
|
||||
@@ -2882,3 +2882,4 @@ lblWinProper=赢
|
||||
lblLossProper=失利
|
||||
lblWinLossRatio=赢得损失比率
|
||||
lblHeal=愈合
|
||||
lblTempHitPoints=临时生命值
|
||||
|
||||
Reference in New Issue
Block a user