Skip to content

Commit

Permalink
Add Overload skill. Remove WMT stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
andor9 committed Aug 18, 2014
1 parent e5b0aa9 commit 944db1d
Show file tree
Hide file tree
Showing 18 changed files with 639 additions and 2,817 deletions.
11 changes: 6 additions & 5 deletions Makefile-tu → Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
MAIN := tyrant_optimize
MAIN := tuo.exe
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,obj-tu/%.o,$(SRCS))
OBJS := $(patsubst %.cpp,obj/%.o,$(SRCS))
INCS := $(wildcard *.h)

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

all: $(MAIN)

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

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

clean:
del /q $(MAIN).exe obj-tu\*.o
del /q $(MAIN).exe obj\*.o

10 changes: 5 additions & 5 deletions Makefile-wmt → Makefile-debug
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
MAIN := tyrant_optimize
MAIN := tuodebug.exe
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,obj-wmt/%.o,$(SRCS))
OBJS := $(patsubst %.cpp,obj-debug/%.o,$(SRCS))
INCS := $(wildcard *.h)

CPPFLAGS := -Wall -Werror -Wno-unused-but-set-variable -std=gnu++11 -O3 -DNDEBUG
CPPFLAGS := -Wall -Werror -std=gnu++11 -O3
LDFLAGS := -lboost_system -lboost_thread -lboost_filesystem -lboost_regex

all: $(MAIN)

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

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

clean:
del /q $(MAIN).exe obj-wmt\*.o
del /q $(MAIN).exe obj-debug\*.o
18 changes: 0 additions & 18 deletions Makefile-tu-debug

This file was deleted.

18 changes: 0 additions & 18 deletions Makefile-wmt-debug

This file was deleted.

80 changes: 0 additions & 80 deletions achievement.h

This file was deleted.

17 changes: 3 additions & 14 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ class Card
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;
bool m_disease_oa;
Faction m_faction;
unsigned m_health;
unsigned m_hidden;
unsigned m_id;
unsigned m_level;
std::string m_name;
unsigned m_phase;
unsigned m_rarity;
unsigned m_replace;
unsigned m_reserve;
unsigned m_set;
bool m_unique;
std::vector<SkillSpec> m_skills[SkillMod::num_skill_activation_modifiers];
unsigned m_skill_value[SkillMod::num_skill_activation_modifiers][num_skills];
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;
Expand All @@ -38,18 +32,13 @@ class Card
m_attack(0),
m_base_id(0),
m_delay(0),
m_disease_oa(false),
m_faction(imperial),
m_health(0),
m_hidden(0),
m_id(0),
m_level(1),
m_name(""),
m_phase(0),
m_rarity(1),
m_replace(0),
m_set(0),
m_unique(false),
m_skills(),
m_type(CardType::assault),
m_top_level_card(this),
Expand All @@ -60,7 +49,7 @@ class Card
std::memset(m_skill_value, 0, sizeof m_skill_value);
}

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

Expand Down
56 changes: 19 additions & 37 deletions cards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdexcept>
#include <cstring>
#include <list>
#include <iostream>

#include "tyrant.h"
#include "card.h"
Expand Down Expand Up @@ -80,24 +81,17 @@ void Cards::organize()
{
card->m_name.erase(pos, 1);
}
#if defined(TYRANT_UNLEASHED)
// set m_top_level_card for non base cards
card->m_top_level_card = by_id(card->m_base_id)->m_top_level_card;
// add a suffix of level to the name of cards; register as alias for the full-level cards (the formal name is without suffix)
if (card == card->m_top_level_card)
{
player_cards_by_name[{simplify_name(card->m_name + "-" + to_string(card->m_level)), card->m_hidden}] = card;
player_cards_by_name[simplify_name(card->m_name + "-" + to_string(card->m_level))] = card;
}
else
{
card->m_name += "-" + to_string(card->m_level);
}
#else
if(card->m_set == 5002)
{
card->m_name += '*';
}
#endif
// Card available to players
if(card->m_set != 0)
{
Expand All @@ -116,67 +110,55 @@ void Cards::organize()
player_structures.push_back(card);
break;
}
case CardType::action: {
player_actions.push_back(card);
break;
}
case CardType::num_cardtypes: {
throw card->m_type;
break;
}
}
std::string simple_name{simplify_name(card->m_name)};
auto card_itr = player_cards_by_name.find({simple_name, card->m_hidden});
if(card_itr == player_cards_by_name.end() || card_itr->second->m_id == card->m_replace)
auto card_itr = player_cards_by_name.find(simple_name);
if (card_itr == player_cards_by_name.end())
{
player_cards_by_name[{simple_name, card->m_hidden}] = card;
player_cards_by_name[simple_name] = card;
}
else
{
// TODO check set visible
// std::cerr << "Duplicated card name [" << card->m_name << "] " << card_itr->second->m_set << ":" << card->m_set << "\n"; // XXX
}
}
}
// Round 3: depend on player_cards_by_name; set abbreviations and [WMT] recipes
#if 0 // TODO refactor precedence
// Round 3: depend on player_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 && player_cards_by_name.find({abbr_name, 0}) == player_cards_by_name.end())
if(abbr_name.length() > 1 && player_cards_by_name.find(abbr_name) == player_cards_by_name.end())
{
player_cards_abbr[abbr_name] = card->m_name;
}
}
}
#if not defined(TYRANT_UNLEASHED)
// update recipes
if(card->m_set == 5002)
{
std::string material_name{simplify_name(card->m_name)};
material_name.erase(material_name.size() - 1); // remove suffix "*"
Card * material_card = player_cards_by_name[{material_name, card->m_hidden}];
// Promo and Unpurchasable Reward cards only require 1 copy
unsigned number = material_card->m_set == 5001 || (material_card->m_set == 5000 && material_card->m_reserve) ? 1 : 2;
// Reward cards still have gold cost
card->m_recipe_cost = material_card->m_set == 5000 ? (card->m_rarity == 4 ? 100000 : 20000) : 0;
card->m_recipe_cards[material_card] = number;
material_card->m_used_for_cards[card] = number;
}
#endif
}
#endif
}

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

2 changes: 1 addition & 1 deletion cards.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Cards
std::vector<Card*> cards;
std::map<unsigned, Card*> cards_by_id;
std::vector<Card*> player_cards;
std::map<std::pair<std::string, unsigned>, Card*> player_cards_by_name;
std::map<std::string, Card*> player_cards_by_name;
std::vector<Card*> player_commanders;
std::vector<Card*> player_assaults;
std::vector<Card*> player_structures;
Expand Down
Loading

0 comments on commit 944db1d

Please sign in to comment.