From d7d201342cd1cff3d90661bf660c5bf94905134a Mon Sep 17 00:00:00 2001 From: Alexander Zeier Date: Sun, 4 Dec 2016 13:59:28 +0100 Subject: [PATCH] Implement Kazakus Potion text formatting --- ts/components/game/Card.tsx | 39 +++++++++++++++++++++++++++++++++++++ ts/components/game/Hand.tsx | 1 + 2 files changed, 40 insertions(+) diff --git a/ts/components/game/Card.tsx b/ts/components/game/Card.tsx index 613dc5c1..78810b4c 100644 --- a/ts/components/game/Card.tsx +++ b/ts/components/game/Card.tsx @@ -2,6 +2,7 @@ import * as React from "react"; import * as _ from "lodash"; import {CardData, EntityProps, OptionProps} from "../../interfaces"; import Attack from "./stats/Attack"; +import Entity from "../../Entity"; import Health from "./stats/Health"; import Cost from "./stats/Cost"; import InHandCardArt from "./visuals/InHandCardArt"; @@ -15,6 +16,7 @@ interface CardProps extends EntityProps, OptionProps, React.ClassAttributes; } export default class Card extends React.Component { @@ -255,6 +257,9 @@ export default class Card extends React.Component { if (data.mechanics && data.mechanics.indexOf("JADE_GOLEM") !== -1) { description = this.formatJadeGolemText(data.text); } + else if (this.props.entity.getTag(GameTag.KAZAKUS_POTION_POWER_1)) { + description = this.formatKazakusPotionText(data.text); + } let modifier = (bonus: number, double: number) => { return (match: string, part1: string) => { @@ -315,4 +320,38 @@ export default class Card extends React.Component { let arg1 = [8, 11, 18].indexOf(value) !== -1 ? "n" : ""; return text.replace("{0}", value + "/" + value).replace("{1}", arg1); } + + private formatKazakusPotionText(text: string): string { + if (!this.props.setAside) { + return text; + } + let data1 = this.props.entity.getTag(GameTag.TAG_SCRIPT_DATA_NUM_1); + let data2 = this.props.entity.getTag(GameTag.TAG_SCRIPT_DATA_NUM_2); + let arg1 = ""; + let arg2 = ""; + this.props.setAside.forEach(e => { + let tagScriptData = e.getTag(GameTag.TAG_SCRIPT_DATA_NUM_1); + if (tagScriptData) { + if (tagScriptData === data1) { + let data = this.props.cards.get(e.cardId); + if (data) { + arg1 = data.text; + } + if (arg2) { + return; + } + } + else if (tagScriptData === data2) { + let data = this.props.cards.get(e.cardId); + if (data) { + arg2 = data.text; + } + if (arg1) { + return; + } + } + } + }); + return text.replace("{0}", arg1).replace("{1}", arg2); + } } diff --git a/ts/components/game/Hand.tsx b/ts/components/game/Hand.tsx index 39f9c039..667d6988 100644 --- a/ts/components/game/Hand.tsx +++ b/ts/components/game/Hand.tsx @@ -77,6 +77,7 @@ export default class Hand extends EntityList { customHealth={customHealth} customAtk={customAtk} customCost={customCost} + setAside={this.props.setAside} />; } }