Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Temporal Backlash ... #3

Open
wants to merge 416 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
416 commits
Select commit Hold shift + click to select a range
9a58736
Support revamped raids.
andor9 Aug 1, 2013
e367521
Fix bug: Blitz status should carry into the next attack phase if the …
andor9 Aug 1, 2013
2142517
Fix edge cases.
andor9 Aug 1, 2013
a6e0973
Improve output message.
andor9 Aug 2, 2013
8fb2323
Fix bug: Frozen assault should carry Blitz status.
andor9 Aug 2, 2013
67d473e
Add option +stdev.
andor9 Aug 3, 2013
584f8ad
Display win rate in percentage instead of fraction.
andor9 Aug 3, 2013
eaf749f
Automatically upgrade owned cards during hill climbing.
andor9 Aug 4, 2013
fddcd28
Claim mission reward cards as owned. Claim your initial deck cards as…
andor9 Aug 4, 2013
fb23cb8
Support buying cards during hill climbing.
andor9 Aug 5, 2013
64486a5
Backfire damage should count in raid damage.
andor9 Aug 6, 2013
f78346a
Blitz status should carry into the next attack phase if the assault d…
andor9 Aug 6, 2013
9b80d58
No automatically claim mission reward cards. Fix card claiming, buyin…
andor9 Aug 7, 2013
6520e2f
Remove operation brute. Add operation reorder.
andor9 Aug 8, 2013
b91075b
Stunned assault can be targeted by Weaken.
andor9 Aug 9, 2013
3739b5e
Fix hill climbing.
andor9 Aug 11, 2013
7318ac7
Reformat output message for raids.
andor9 Aug 11, 2013
540dde6
Fix operation reorder. Add option hand for debugging.
andor9 Aug 12, 2013
1767013
Calculate raid damage based on the final HP of enemy commander.
andor9 Aug 16, 2013
f6dcdb9
Add Phase skill.
andor9 Aug 23, 2013
40fd849
Support battleground effects in a more flexible way.
andor9 Aug 29, 2013
981c22c
Raid damage is 100 for slaying boss in Arctis Vanguard.
andor9 Sep 10, 2013
4f7da8d
Support harmonic mean.
andor9 Sep 12, 2013
7f12e1c
Add debug info.
andor9 Sep 22, 2013
f4907c7
Support battleground effect for raids.
andor9 Sep 26, 2013
6bfeecd
Honor summon limit (29 + deck size).
andor9 Sep 26, 2013
8dee226
Fix typo: automatically apply battleground effect for quests.
andor9 Sep 29, 2013
81f50d3
Add debug function: specify enemy hand.
andor9 Sep 30, 2013
a5a33ca
Fix debug info.
andor9 Sep 30, 2013
40fff5b
Support battleground effect Harsh Conditions (-e 20).
andor9 Oct 22, 2013
8a5c3df
Fix display of win rate in defense mode.
andor9 Oct 22, 2013
ca91744
Summon on Death/Attacked/Kill now count towards the Summon Limit.
andor9 Oct 24, 2013
993070c
Support battleground effect for missions.
andor9 Oct 30, 2013
603944d
Support 'hidden only' cards.
andor9 Nov 2, 2013
5175444
Support Tyrant Unleashed.
andor9 Mar 29, 2014
6ac739f
Support Fortresses.
andor9 Apr 7, 2014
b16b082
Support unleashed battleground.
andor9 Apr 7, 2014
5c432b9
Support skill cooldown.
andor9 May 1, 2014
0437f3e
Improve unleashed battleground (interactive w/ inhibit).
andor9 May 1, 2014
346413c
Use recipes xml.
andor9 May 1, 2014
f7868ce
Use tu_optimize style card name.
andor9 May 3, 2014
026cd1c
Add end phase and fix Poison skill.
andor9 May 4, 2014
73f9b72
Support nested group & regex in custom.txt.
andor9 May 10, 2014
3ba8aba
Add Corrosive skill.
andor9 May 15, 2014
c32558d
Fix bug: Protect should take effect on Poison.
andor9 May 16, 2014
67637d2
Merge recipe logic for WMT and TU
andor9 May 17, 2014
8188397
Improve hill climbing to better support fusion.
andor9 May 17, 2014
3271993
Improve hill climbing to support de-fusion.
andor9 May 18, 2014
ff31a9d
Fix rarity names.
andor9 May 18, 2014
49621ed
Fix display.
andor9 May 18, 2014
23133d3
Add back level-1 missions.
andor9 May 18, 2014
280b673
Fix reorder.
andor9 May 23, 2014
d53e0bd
Improve debug info for Corrosive.
andor9 May 24, 2014
cd477f7
Improve level-1 mission names.
andor9 May 24, 2014
4a3d202
Improve debug info.
andor9 May 25, 2014
3802c93
Improve hill climbing to support commander downgrading.
andor9 Jun 4, 2014
3f171eb
Restructure skills.
andor9 Jun 4, 2014
67b56d5
Fix bug: passive skills of Mutants.
andor9 Jun 5, 2014
54a3651
Extend hash encoding.
andor9 Jun 22, 2014
0d98f36
Support mission levels.
andor9 Jun 24, 2014
a73158b
Add Flurry skill.
andor9 Jun 24, 2014
e5b0aa9
Fine tune for TU.
andor9 Jun 30, 2014
944db1d
Add Overload skill. Remove WMT stuff.
andor9 Aug 18, 2014
ceb480a
Fix minor bugs and behaviors.
andor9 Aug 19, 2014
6c7f1e9
Modify error message.
andor9 Aug 21, 2014
79b976a
Fix skill name Armor.
andor9 Aug 21, 2014
5a9ecc6
Support -o=<card list>.
andor9 Aug 21, 2014
77349fa
Fix compile complaint.
andor9 Aug 21, 2014
95b7c44
- OS X compilation fixes
ksvintsov Aug 21, 2014
777176a
- OS X compilation fixes
ksvintsov Aug 21, 2014
48d2814
Fix skill name Armor/Armored (both acceptable).
andor9 Aug 21, 2014
0a2901f
Fix faction Progenitor.
andor9 Aug 21, 2014
395a1af
Merge pull request #8 from ksvintsov/unleashed
andor9 Aug 21, 2014
9988a3c
Merge branch 'unleashed' of https://github.com/andor9/tyrant_optimize…
andor9 Aug 21, 2014
75f1f2c
Support raid levels. Add raid Apocalypse.
andor9 Aug 22, 2014
7cbd1ac
Add mode Raid: Optimize against Average Raid Damage (ARD).
andor9 Aug 22, 2014
9066672
Update raids.xml.
andor9 Aug 22, 2014
3a10cad
Fine tune to rnd.
andor9 Aug 23, 2014
4c5e79a
Show error message instead of exception on wrong fortress flag.
andor9 Aug 23, 2014
29b8330
Show more debug info for mission/raid levels.
andor9 Aug 23, 2014
bfac729
Fix false alert of BGE.
andor9 Aug 25, 2014
63c958b
Version 2.1.2.
andor9 Aug 25, 2014
fe68bd5
Fix bug: wrong results when against your own deck with fortresses.
andor9 Aug 27, 2014
79d51b8
- fix coredump in case of recipes for unknown cards (for example, fus…
ksvintsov Aug 29, 2014
1ea68c3
Support more BGEs.
andor9 Sep 4, 2014
dbae52f
Merge pull request #9 from ksvintsov/unleashed
andor9 Sep 5, 2014
e83d6c0
Add mode Brawl: Optimize against brawl score. Refactor hill climbing.
andor9 Sep 8, 2014
fad006a
Patched for GNU C++ compatibility
emcn Sep 9, 2014
d7c303e
Merge pull request #10 from emcn/unleashed
andor9 Sep 9, 2014
f37a253
Add Valor skill.
andor9 Sep 11, 2014
8a741b3
Support raid #2 Jotun Max.
andor9 Sep 11, 2014
73cd3c7
Support <mission>-10 and <raid>-26.
andor9 Sep 15, 2014
b3f8ad8
Fix error message for wrong efort input.
andor9 Sep 18, 2014
881f7f6
Update Valor skill.
andor9 Sep 18, 2014
be87fde
Fix raid/mission levels.
andor9 Sep 20, 2014
9124cc2
Fix typo.
andor9 Sep 20, 2014
b4ac287
Improve error message for wrong hash.
andor9 Oct 1, 2014
8a959c3
Add BGE Reaping.
andor9 Oct 10, 2014
e0451d4
Update Valor skill: triggered before commander acts.
andor9 Oct 21, 2014
09a8321
Update Brawl mode.
andor9 Oct 29, 2014
6ddf0d6
Support raid #3 Forsaken Horde.
andor9 Oct 30, 2014
f5a24e3
Add Legion skill.
andor9 Oct 30, 2014
941cdd2
Update Legion skill.
andor9 Oct 30, 2014
e276932
Add endgame flag: attempt max-level and fused cards only.
andor9 Oct 30, 2014
75557e8
Improve message.
andor9 Oct 30, 2014
9b61ac1
Improve warning message: cards in your initial deck are not in ownedc…
andor9 Oct 30, 2014
7ba9018
Add Payback skill.
andor9 Nov 1, 2014
11b90a3
Support raid #4 Oluth.
andor9 Nov 14, 2014
d2000cb
Suppress unexpected warning message.
andor9 Nov 16, 2014
e420f74
Add BGE Bloodlust.
andor9 Nov 20, 2014
caae795
Fix BGE Bloodlust: prevented damage should not count.
andor9 Nov 21, 2014
3dc70d0
Support Raid #5 Carnifex
andor9 Dec 12, 2014
e1b0663
Support CSV files for customdecks.txt.
andor9 Dec 12, 2014
cedf844
Add tw flag for simming guild war offense and defense simultaneously
mjdoom Dec 18, 2014
5873298
Support Raid #6 Karkinos.
andor9 Jan 23, 2015
844901c
Update Raid #6 Karkinos.
andor9 Jan 24, 2015
bcc3f2d
Merge pull request #18 from mjdoom/unleashed
andor9 Jan 29, 2015
8dec5e8
Fix skill Overload.
andor9 Jan 29, 2015
d385ba7
Shrink your deck if too long.
andor9 Jan 29, 2015
9c92486
Add back Lock Card function.
andor9 Jan 29, 2015
bbe87c9
Fix skill Flurry: works for structures.
andor9 Feb 11, 2015
932fbe5
Fix bug: endgame should test maxeded cards only.
andor9 Feb 11, 2015
826ea09
Fix skill Payback (Issue #22)
andor9 Feb 19, 2015
7e3487d
Support Raid #7 Brood Mother.
andor9 Feb 19, 2015
ec4933d
Version 2.4.5.
andor9 Feb 19, 2015
d7d4efe
Fix bug: "Lock" commander.
andor9 Feb 20, 2015
b2bbef1
Support Campaign. Add flag vip.
andor9 Feb 24, 2015
9da5a0a
Fix bug: score shorter deck correctly in campaign mode.
andor9 Feb 24, 2015
48bcf58
Fix campaign decks Tartarus Vanguard.
andor9 Feb 24, 2015
1114241
Fix level 6 deck of Tartarus Vanguard.
andor9 Feb 26, 2015
b0c6597
Fix segfault when initial deck has no commander
odinguru Jan 1, 2015
9894e6f
Warning instead of error on multiple commanders in initial deck
odinguru Jan 1, 2015
e45b90a
Improve handling of over sized initial decks
odinguru Feb 2, 2015
d284a9b
Merge pull request #25 from odinguru/unleashed
andor9 Mar 6, 2015
39f3a91
Update formula of brawl score.
andor9 Mar 8, 2015
c1a4715
Merge branch 'unleashed' of https://github.com/andor9/tyrant_optimize…
andor9 Mar 8, 2015
17dd842
Add flag freeze N: freeze first N cards.
andor9 Mar 9, 2015
73a2ff3
Fix skill Flurry: works for commander.
andor9 Mar 15, 2015
e992592
Support Campaign Brimstone.
andor9 Mar 15, 2015
eaac353
Fix campaign Brimstone.
andor9 Mar 17, 2015
880d018
Add skills Refresh and Evolve.
andor9 Mar 18, 2015
1b32223
Update Raid deck.
andor9 Mar 18, 2015
89556ed
Update Raid deck.
andor9 Mar 21, 2015
5cb8df3
Reorganize status. Fix skill Evade on structure.
andor9 Mar 22, 2015
edd2950
Add skill Avenge.
andor9 Apr 8, 2015
041b88a
Fix bug: berserk.
andor9 Apr 8, 2015
bddfdcd
Version 2.7.1
andor9 Apr 8, 2015
27ef28b
Support Raid #9 Talos (spoiler).
andor9 Apr 9, 2015
c4bae0c
Add decks for campaign Secrets Revealed.
andor9 Apr 17, 2015
73c713c
Update campaign deck.
andor9 Apr 18, 2015
10039f7
Support more BGE.
andor9 Apr 20, 2015
2e777b1
Support Evolve BGE.
andor9 Apr 21, 2015
34d87c2
Update OSX Makefile.
andor9 May 5, 2015
6346b2e
Add BGE Counterflux. Support multiple BGEs.
andor9 May 7, 2015
f29efc8
Add flag _<suffix> to load extra data files.
andor9 May 7, 2015
42dd946
Fix bug for flag _.
andor9 May 8, 2015
ca79625
Offer unlimited common/rare cards as material for fund under flag end…
andor9 May 13, 2015
b69c1f5
Fix bug: Counterflux should work on assaults only.
andor9 May 14, 2015
77f8781
Fix bug: Counterflux should not heal died units.
andor9 May 15, 2015
ede1448
Support Campaign Deidon.
andor9 May 15, 2015
bf9cc15
Support BGE Counterflux Y where Y is the denominator (X/Y). Y=4 by de…
andor9 May 16, 2015
4e4aa66
Show amount of units in optimized deck.
andor9 May 17, 2015
e19f738
Add skill Venom.
andor9 May 19, 2015
ec04113
Move amount of units to beginning of line.
andor9 May 20, 2015
db5e6ef
Support Raid #10 Gore Typhon
andor9 May 20, 2015
492216e
Fix debug info.
andor9 May 21, 2015
009f400
Fix bug: raid damage.
andor9 May 22, 2015
74b29ca
Update Raid #10 "Gore Typhon Raid".
andor9 May 22, 2015
0d1dbf0
Simulate in-game behavior of Evolve: target on inactive units even if…
andor9 Jun 11, 2015
884fb72
Fix bug: campaign score.
andor9 Jun 12, 2015
14486c0
Support Campaign Kalihmah.
andor9 Jun 12, 2015
75e2cf4
Support BGE Fortification.
andor9 Jun 12, 2015
4a2106b
Support -e "": no effect.
andor9 Jun 17, 2015
0aa4915
Add skill Mend.
andor9 Jun 17, 2015
89c2608
Fix bug: BGE Fortification.
andor9 Jun 18, 2015
156ea97
Support Raid #11 "Supremacy Raid".
andor9 Jun 18, 2015
16778b3
Update card id ranges.
andor9 Jun 26, 2015
fe9d598
Remove flags tw and +stdev. Add flag quest.
andor9 Jun 27, 2015
aad1109
No longer warn for new skills.
andor9 Jun 27, 2015
ad35dc6
Fix bug: should not calculate quest score in non-quest mode.
andor9 Jun 28, 2015
40eb90d
Support Campaign Warden.
andor9 Jul 10, 2015
3d0416e
Update campaign deck.
andor9 Jul 10, 2015
ebdb926
Update campaign decks.
andor9 Jul 11, 2015
13a54d5
Add quest cs (cards survival).
andor9 Jul 13, 2015
33b11e0
Support Raid #12 "Intrepid Raid".
andor9 Jul 14, 2015
da1efc4
Add skill Mortar.
andor9 Jul 14, 2015
1952120
v2.10.2
andor9 Jul 14, 2015
08dc194
Support BGE TurningTides.
andor9 Jul 15, 2015
6c55306
Fix bug: Mortar should honor Enfeeble and Protect.
andor9 Aug 6, 2015
878afaa
Support BGE EnduringRage (no space in name).
andor9 Aug 12, 2015
6d248f4
Cleanup action cards.
andor9 Aug 13, 2015
29eae12
Add skill Swipe.
andor9 Aug 17, 2015
66744c3
Support Raid #13 "Pantheon Raid".
andor9 Aug 20, 2015
084635c
Error tolerance for raids.xml.
andor9 Aug 20, 2015
5f9b2b8
Fix bug: BGE EnduringRage should not heal dead units (for example kil…
andor9 Aug 21, 2015
827dc74
Improve handling of card name duplication. Honor commander_max_level.
andor9 Aug 26, 2015
3cd92c6
Support Campaign Gateway.
andor9 Aug 30, 2015
cf9b71f
Add alias for Gateway decks.
andor9 Aug 30, 2015
f6af61a
Support BGE Divert.
andor9 Sep 15, 2015
9aa2853
Support optional "to" in -e "Evolve A to B"
andor9 Sep 17, 2015
ed1af41
Add skill Rupture.
andor9 Sep 23, 2015
73a634c
Add quest suoc - skill use on card.
andor9 Sep 24, 2015
e9ace4c
Support Raid #14 "Prometheus Raid".
andor9 Sep 24, 2015
5737d95
Fix compiler warning.
andor9 Sep 24, 2015
a381389
Fix bug: enhance BGE.
andor9 Sep 25, 2015
7f0986b
Simulate bizarre in-game behavior: Swipe even if attack is 0.
andor9 Sep 27, 2015
c28078e
Revert bizzare in-game behaviors.
andor9 Sep 29, 2015
7479d4f
Support Campaign Emrys Ascended (Emry).
andor9 Oct 2, 2015
491bb41
Simulate in-game behavior: Swipe if attack is corroded to 0.
andor9 Oct 3, 2015
3e4f803
Fix bug: Corrosive status should be removed if attack is 0.
andor9 Oct 4, 2015
dd25f14
Update Campaign decks.
andor9 Oct 4, 2015
b2e00df
Fix bug: Evolve and Enhance should not target jammed units.
andor9 Oct 9, 2015
5aa981f
No longer support multiple operations.
andor9 Oct 9, 2015
a2a8719
Deck names are case-insensitive now.
andor9 Oct 9, 2015
7c06ec5
Support BGE Brigade.
andor9 Oct 28, 2015
2a8cc9a
Update skills Enhance and Evolve.
andor9 Oct 28, 2015
3eeea8d
Access new XML files.
andor9 Nov 6, 2015
c6b061e
Add skill Rush.
andor9 Nov 12, 2015
6fa616c
Fix compiler warning sign-compare.
andor9 Nov 12, 2015
3820d5c
Fix skill Rush working with Valor.
andor9 Nov 12, 2015
19606db
Update Lilith Raid deck.
andor9 Nov 15, 2015
2ce1e4f
Update Lilith Raid deck.
andor9 Nov 15, 2015
172b71d
Support Campaign Mephisopheles (Meph).
andor9 Nov 29, 2015
78cca6e
Update campaign decks.
andor9 Dec 3, 2015
5c8fad5
Support BGE Heroism.
andor9 Dec 3, 2015
221d29b
Rename BGE Reaping to Revenge.
andor9 Dec 3, 2015
3f19fe9
Support multiple operations again.
andor9 Dec 3, 2015
c507df3
Update the caster of BGE Heroism.
andor9 Dec 3, 2015
097ea9f
Rename variables.
andor9 Dec 4, 2015
dc89eb3
Update the caster of skills triggered by BGE (Revenue and Turning Tid…
andor9 Dec 4, 2015
8f6d3fa
Update BGE Heroism.
andor9 Dec 9, 2015
7b4caa6
Fix `heroism` BGE
gnn Dec 17, 2015
43db738
Merge pull request #39 from gnn/unleashed
andor9 Dec 20, 2015
51e2f05
v2.14.2
andor9 Dec 20, 2015
a6a0a99
Add cards_section_9.xml.
andor9 Dec 20, 2015
a6bb74a
Support fortress in Mission deck.
andor9 Dec 22, 2015
e66b85f
Add skill Sunder.
andor9 Jan 6, 2016
a648608
Support Raid #16 "Calamity Raid".
andor9 Jan 6, 2016
79ab6e8
Fix bug: skill Sunder.
andor9 Jan 6, 2016
644b686
Update raid deck.
andor9 Jan 8, 2016
267a563
Add flag ye and ee.
andor9 Feb 5, 2016
c0b21d3
Support BGE Virulence.
andor9 Feb 7, 2016
68059d7
Fix bug: crash using Structures and BGE Virulence.
andor9 Feb 8, 2016
ef2da9c
Review on-death workflow to fix crash.
andor9 Feb 11, 2016
d5932eb
Support BGE aliases (data/bges.txt).
andor9 Feb 22, 2016
91b3cdd
Support skill Allegiance.
andor9 Feb 24, 2016
9718543
Support Raid #17 "Warden Raid".
andor9 Feb 25, 2016
2bca30a
Fix bug: crash.
andor9 Feb 25, 2016
01b0eda
Fix bug: Allegiance should be triggered only by *another* card.
andor9 Feb 25, 2016
f700fe5
Update raid deck.
andor9 Feb 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj/**
tu_optimize
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MAIN := tuo.exe
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,obj/%.o,$(SRCS))
INCS := $(wildcard *.h)

CPPFLAGS := -Wall -Werror -std=gnu++11 -O3 -DNDEBUG
LDFLAGS := -lboost_system -lboost_thread -lboost_filesystem -lboost_regex

all: $(MAIN)

obj/%.o: %.cpp $(INCS)
$(CXX) $(CPPFLAGS) -o $@ -c $<

$(MAIN): $(OBJS)
$(CXX) -o $@ $(OBJS) $(LDFLAGS)

clean:
del /q $(MAIN).exe obj\*.o
18 changes: 18 additions & 0 deletions Makefile-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MAIN := tuodebug.exe
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,obj-debug/%.o,$(SRCS))
INCS := $(wildcard *.h)

CPPFLAGS := -Wall -Werror -std=gnu++11 -O3
LDFLAGS := -lboost_system -lboost_thread -lboost_filesystem -lboost_regex

all: $(MAIN)

obj-debug/%.o: %.cpp $(INCS)
$(CXX) $(CPPFLAGS) -o $@ -c $<

$(MAIN): $(OBJS)
$(CXX) -o $@ $(OBJS) $(LDFLAGS)

clean:
del /q $(MAIN).exe obj-debug\*.o
18 changes: 18 additions & 0 deletions Makefile.osx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MAIN := tuo
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,obj/%.o,$(SRCS))
INCS := $(wildcard *.h)

CPPFLAGS := -Wall -Werror -std=c++11 -stdlib=libc++ -O3 -I/usr/local/include -Wno-deprecated-register -DNDEBUG
LDFLAGS := lib/libboost_system-mt.a lib/libboost_thread-mt.a lib/libboost_filesystem-mt.a lib/libboost_regex-mt.a -L/usr/local/lib -Bstatic

all: $(MAIN)

obj/%.o: %.cpp ${INCS}
$(CXX) $(CPPFLAGS) -o $@ -c $<

$(MAIN): $(OBJS)
$(CXX) -o $@ $(OBJS) $(LDFLAGS)

clean:
rm -f $(MAIN) obj/*.o
58 changes: 58 additions & 0 deletions card.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef CARD_H_INCLUDED
#define CARD_H_INCLUDED

#include <cstring>
#include <string>
#include <vector>
#include "tyrant.h"

class Card
{
public:
unsigned m_attack;
unsigned m_base_id; // The id of the original card if a card is unique and alt/upgraded. The own id of the card otherwise.
unsigned m_delay;
Faction m_faction;
unsigned m_health;
unsigned m_id;
unsigned m_level;
unsigned m_fusion_level;
std::string m_name;
unsigned m_rarity;
unsigned m_set;
std::vector<SkillSpec> m_skills;
unsigned m_skill_value[num_skills];
CardType::CardType m_type;
const Card* m_top_level_card; // [TU] corresponding full-level card
unsigned m_recipe_cost;
std::map<const Card*, unsigned> m_recipe_cards;
std::map<const Card*, unsigned> m_used_for_cards;

public:
Card() :
m_attack(0),
m_base_id(0),
m_delay(0),
m_faction(imperial),
m_health(0),
m_id(0),
m_level(1),
m_fusion_level(0),
m_name(""),
m_rarity(1),
m_set(0),
m_skills(),
m_type(CardType::assault),
m_top_level_card(this),
m_recipe_cost(0),
m_recipe_cards(),
m_used_for_cards()
{
std::memset(m_skill_value, 0, sizeof m_skill_value);
}

void add_skill(Skill id, unsigned x, Faction y, unsigned n, unsigned c, Skill s, Skill s2, bool all);
const Card* upgraded() const { return this == m_top_level_card ? this : m_used_for_cards.begin()->first; }
};

#endif
173 changes: 173 additions & 0 deletions cards.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#include "cards.h"

#include <boost/tokenizer.hpp>
#include <sstream>
#include <stdexcept>
#include <cstring>
#include <list>
#include <iostream>

#include "tyrant.h"
#include "card.h"

std::string simplify_name(const std::string& card_name)
{
std::string simple_name;
for(auto c : card_name)
{
if(!strchr(";:,\"'! ", c))
{
simple_name += ::tolower(c);
}
}
return(simple_name);
}

std::list<std::string> get_abbreviations(const std::string& name)
{
std::list<std::string> abbr_list;
boost::tokenizer<boost::char_delimiters_separator<char>> word_token{name, boost::char_delimiters_separator<char>{false, " -", ""}};
std::string initial;
auto token_iter = word_token.begin();
for(; token_iter != word_token.end(); ++token_iter)
{
abbr_list.push_back(simplify_name(std::string{token_iter->begin(), token_iter->end()}));
initial += *token_iter->begin();
}
abbr_list.push_back(simplify_name(initial));
return(abbr_list);
}

//------------------------------------------------------------------------------
Cards::~Cards()
{
for (Card* c: all_cards) { delete(c); }
}

const Card* Cards::by_id(unsigned id) const
{
const auto cardIter = cards_by_id.find(id);
if(cardIter == cards_by_id.end())
{
throw std::runtime_error("No card with id " + to_string(id));
}
else
{
return(cardIter->second);
}
}
//------------------------------------------------------------------------------
void Cards::organize()
{
cards_by_id.clear();
player_cards.clear();
cards_by_name.clear();
player_commanders.clear();
player_assaults.clear();
player_structures.clear();
// Round 1: set cards_by_id
for(Card* card: all_cards)
{
cards_by_id[card->m_id] = card;
}
// Round 2: depend on cards_by_id / by_id(); update m_name, [TU] m_top_level_card etc.; set cards_by_name;
for(Card* card: all_cards)
{
// Remove delimiters from card names
size_t pos;
while((pos = card->m_name.find_first_of(";:,")) != std::string::npos)
{
card->m_name.erase(pos, 1);
}
// set m_top_level_card for non base cards
card->m_top_level_card = by_id(card->m_base_id)->m_top_level_card;
// Cards available ("visible") to players have priority
std::string base_name = card->m_name;
if (card == card->m_top_level_card)
{
add_card(card, card->m_name + "-" + to_string(card->m_level));
}
else
{
card->m_name += "-" + to_string(card->m_level);
}
add_card(card, card->m_name);
}
#if 0 // TODO refactor precedence
// Round 3: depend on cards_by_name; set abbreviations
for(Card* card: cards)
{
// generate abbreviations
if(card->m_set > 0)
{
for(auto&& abbr_name : get_abbreviations(card->m_name))
{
if(abbr_name.length() > 1 && cards_by_name.find(abbr_name) == cards_by_name.end())
{
player_cards_abbr[abbr_name] = card->m_name;
}
}
}
}
#endif
}

void Cards::add_card(Card * card, const std::string & name)
{
std::string simple_name{simplify_name(name)};
auto card_itr = cards_by_name.find(simple_name);
signed old_visible = card_itr == cards_by_name.end() ? -1 : visible_cardset.count(card_itr->second->m_set);
signed new_visible = visible_cardset.count(card->m_set);
if (card_itr != cards_by_name.end())
{
if (old_visible == new_visible)
{
ambiguous_names.insert(simple_name);
}
_DEBUG_MSG(2, "Duplicated card name \"%s\" [%u] set=%u (visible=%u) : [%u] set=%u (visible=%u)\n", name.c_str(), card_itr->second->m_id, card_itr->second->m_set, old_visible, card->m_id, card->m_set, new_visible);
}
else if (old_visible < new_visible)
{
ambiguous_names.erase(simple_name);
cards_by_name[simple_name] = card;
if (new_visible)
{
player_cards.push_back(card);
switch(card->m_type)
{
case CardType::commander: {
player_commanders.push_back(card);
break;
}
case CardType::assault: {
player_assaults.push_back(card);
break;
}
case CardType::structure: {
player_structures.push_back(card);
break;
}
case CardType::num_cardtypes: {
throw card->m_type;
break;
}
}
}
}
}

// class Card
void Card::add_skill(Skill id, unsigned x, Faction y, unsigned n, unsigned c, Skill s, Skill s2, bool all)
{
for(auto it = m_skills.begin(); it != m_skills.end(); ++ it)
{
if(it->id == id)
{
m_skills.erase(it);
break;
}
}
m_skills.push_back({id, x, y, n, c, s, s2, all});
m_skill_value[id] = x ? x : n ? n : 1;
}

33 changes: 33 additions & 0 deletions cards.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef CARDS_H_INCLUDED
#define CARDS_H_INCLUDED

#include <map>
#include <string>
#include <unordered_set>
#include <vector>

class Card;

class Cards
{
public:
~Cards();

std::vector<Card*> all_cards;
std::map<unsigned, Card*> cards_by_id;
std::vector<Card*> player_cards;
std::map<std::string, Card*> cards_by_name;
std::vector<Card*> player_commanders;
std::vector<Card*> player_assaults;
std::vector<Card*> player_structures;
std::map<std::string, std::string> player_cards_abbr;
std::unordered_set<unsigned> visible_cardset;
std::unordered_set<std::string> ambiguous_names;
const Card * by_id(unsigned id) const;
void organize();
void add_card(Card * card, const std::string & name);
};

std::string simplify_name(const std::string& card_name);

#endif
Loading