From 928ca3497a484ebd7142880099f6f712a094733d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Snoen?= Date: Sat, 21 Dec 2013 19:31:32 +0100 Subject: [PATCH] More code compliance. New tests. --- .../mtg/bin/Res/test/executioners_swing.txt | 42 +++++++++++++++++++ .../mtg/bin/Res/test/executioners_swing2.txt | 42 +++++++++++++++++++ .../mtg/bin/Res/test/executioners_swing3.txt | 34 +++++++++++++++ projects/mtg/src/CardGui.cpp | 7 +++- projects/mtg/src/TargetChooser.cpp | 10 +++-- 5 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 projects/mtg/bin/Res/test/executioners_swing.txt create mode 100644 projects/mtg/bin/Res/test/executioners_swing2.txt create mode 100644 projects/mtg/bin/Res/test/executioners_swing3.txt diff --git a/projects/mtg/bin/Res/test/executioners_swing.txt b/projects/mtg/bin/Res/test/executioners_swing.txt new file mode 100644 index 000000000..baabe2c48 --- /dev/null +++ b/projects/mtg/bin/Res/test/executioners_swing.txt @@ -0,0 +1,42 @@ +#NAME: Executioner's Swing +#DESC: Checks targetability +#DESC: Test that can target creature that damaged creature this turn + +[INIT] +combatattackers + +[PLAYER1] +inplay:Grizzly Bears + +[PLAYER2] +inplay:Flying Men,Swamp,Plains +hand:Executioner's Swing + +[DO] +Grizzly Bears +next +Flying Men +next +next +next + +# second main +# kill bear +yes +Swamp +Plains +Executioner's Swing +Grizzly Bears +endinterruption + +[ASSERT] +secondmain + +[PLAYER1] +graveyard:Grizzly Bears + +[PLAYER2] +graveyard:Executioner's Swing,Flying Men +inplay:Plains,Swamp + +[END] diff --git a/projects/mtg/bin/Res/test/executioners_swing2.txt b/projects/mtg/bin/Res/test/executioners_swing2.txt new file mode 100644 index 000000000..cb484e8d7 --- /dev/null +++ b/projects/mtg/bin/Res/test/executioners_swing2.txt @@ -0,0 +1,42 @@ +#NAME: Executioner's Swing +#DESC: Checks targetability +#DESC: Test that can target creature that damaged player + +[INIT] +combatattackers + +[PLAYER1] +inplay:Grizzly Bears + +[PLAYER2] +inplay:Swamp,Plains +hand:Executioner's Swing + +[DO] +Grizzly Bears +next +next +next +next + +# second main +# kill bear +yes +Swamp +Plains +Executioner's Swing +Grizzly Bears +endinterruption + +[ASSERT] +secondmain + +[PLAYER1] +graveyard:Grizzly Bears + +[PLAYER2] +graveyard:Executioner's Swing +inplay:Plains,Swamp +life:18 + +[END] diff --git a/projects/mtg/bin/Res/test/executioners_swing3.txt b/projects/mtg/bin/Res/test/executioners_swing3.txt new file mode 100644 index 000000000..433164fed --- /dev/null +++ b/projects/mtg/bin/Res/test/executioners_swing3.txt @@ -0,0 +1,34 @@ +#NAME: Executioner's Swing +#DESC: Checks targetability +#DESC: Prove that can't target passive creature + +[INIT] +secondmain + +[PLAYER1] +inplay:Grizzly Bears + +[PLAYER2] +manapool:{B}{W} +hand:Executioner's Swing + +[DO] +# attempt to kill bear +yes +Swamp +Plains +Executioner's Swing +Grizzly Bears +endinterruption + +[ASSERT] +secondmain + +[PLAYER1] +inplay:Grizzly Bears + +[PLAYER2] +hand:Executioner's Swing +manapool:{W}{B} + +[END] diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 589d54eb8..0b5b9d44a 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -1227,9 +1227,12 @@ bool CardGui::FilterCard(MTGCard * _card,string filter) //creature dealt damage to anything else if (attribute.find("damager") != string::npos) { - if (minus){ + if (minus) + { cd.CDdamager = -1; - } else { + } + else + { cd.CDdamager = 1; } } diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index fba54658c..e69f29702 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -486,10 +486,14 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta } } //creature dealt damage to anything - else if (attribute.find("damager") != string::npos){ - if (minus){ + else if (attribute.find("damager") != string::npos) + { + if (minus) + { cd->CDdamager = -1; - } else { + } + else + { cd->CDdamager = 1; } }