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

More than one dominion is not accepted? #22

Open
wants to merge 4 commits into
base: merged
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion SimpleTUOptimizeStarter.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Gui, Add, Edit, vSimOptions r1 xs w600, %IniSimOptions%
Gui, Add, Button, default r2 w100 x100 y+15 section, Simulate
Gui, Add, Checkbox, vx86 Checked%Inix86%, x86 (32-bit)
Gui, Add, Button, r2 w100 ys xs+200, Exit
Gui, Show,, Simple Tyrant Unleashed Optimize Starter v2.54.2
Gui, Show,, Simple Tyrant Unleashed Optimize Starter v2.54.5
return

ButtonSimulate:
Expand Down
4 changes: 4 additions & 0 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Card
unsigned m_set;
std::vector<SkillSpec> m_skills;
std::vector<SkillSpec> m_skills_on_play;
//APN
std::vector<SkillSpec> m_skills_on_attacked;
std::vector<SkillSpec> m_skills_on_death;
unsigned m_skill_value[Skill::num_skills];
Skill::Trigger m_skill_trigger[Skill::num_skills];
Expand All @@ -48,6 +50,8 @@ class Card
m_set(0),
m_skills(),
m_skills_on_play(),
//APN
m_skills_on_attacked(),
m_skills_on_death(),
m_type(CardType::assault),
m_category(CardCategory::normal),
Expand Down
6 changes: 6 additions & 0 deletions cards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ void Card::add_skill(Skill::Trigger trigger, Skill::Skill id, unsigned x, Factio
case Skill::Trigger::play:
storage = &m_skills_on_play;
break;
//APN
case Skill::Trigger::attacked:
storage = &m_skills_on_attacked;
break;
case Skill::Trigger::death:
storage = &m_skills_on_death;
break;
Expand All @@ -205,6 +209,8 @@ void Card::add_skill(Skill::Trigger trigger, Skill::Skill id, unsigned x, Factio
m_skills.erase(std::remove_if(m_skills.begin(), m_skills.end(), pred), m_skills.end());
m_skills_on_play.erase(std::remove_if(m_skills_on_play.begin(), m_skills_on_play.end(), pred), m_skills_on_play.end());
m_skills_on_death.erase(std::remove_if(m_skills_on_death.begin(), m_skills_on_death.end(), pred), m_skills_on_death.end());
//APN
m_skills_on_attacked.erase(std::remove_if(m_skills_on_attacked.begin(), m_skills_on_attacked.end(), pred), m_skills_on_attacked.end());
}
// add a new one
storage->push_back({id, x, y, n, c, s, s2, all, card_id});
Expand Down
16 changes: 16 additions & 0 deletions data/raids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,22 @@
</card_pool>
</deck>
</raid>

<raid>
<id>41</id>
<name>Door of Khensu Raid</name>
<commander>25782</commander>
<fortress_card id="18348"/>
<levels>26</levels>
<deck>
<always_include>
<card replicates="4">55790</card>
<card replicates="3">55800</card>
<card replicates="3">55810</card>
</always_include>
</deck>
</raid>

<!-- END of Raids -->


Expand Down
17 changes: 16 additions & 1 deletion sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ std::string card_description(const Cards& cards, const Card* c)
if (c->m_faction != allfactions) { desc += " " + faction_names[c->m_faction]; }
for (auto& skill: c->m_skills_on_play) { desc += ", " + skill_description(cards, skill, Skill::Trigger::play); }
for (auto& skill: c->m_skills) { desc += ", " + skill_description(cards, skill, Skill::Trigger::activate); }
//APN
for (auto& skill: c->m_skills_on_attacked) { desc += ", " + skill_description(cards, skill, Skill::Trigger::attacked); }
for (auto& skill: c->m_skills_on_death) { desc += ", " + skill_description(cards, skill, Skill::Trigger::death); }
return desc;
}
Expand Down Expand Up @@ -312,12 +314,15 @@ std::string CardStatus::description() const
if (m_enraged) { desc += ", enraged " + to_string(m_enraged); }
if (m_entrapped) { desc += ", entrapped " + to_string(m_entrapped); }
// if(m_step != CardStep::none) { desc += ", Step " + to_string(static_cast<int>(m_step)); }
const Skill::Trigger s_triggers[] = { Skill::Trigger::play, Skill::Trigger::activate, Skill::Trigger::death };
//APN
const Skill::Trigger s_triggers[] = { Skill::Trigger::play, Skill::Trigger::activate, Skill::Trigger::death , Skill::Trigger::attacked};
for (const Skill::Trigger& trig: s_triggers)
{
std::vector<SkillSpec> card_skills(
(trig == Skill::Trigger::play) ? m_card->m_skills_on_play :
(trig == Skill::Trigger::activate) ? m_card->m_skills :
//APN
(trig == Skill::Trigger::attacked) ? m_card->m_skills_on_attacked :
(trig == Skill::Trigger::death) ? m_card->m_skills_on_death :
std::vector<SkillSpec>());

Expand All @@ -344,6 +349,7 @@ std::string CardStatus::description() const
{
desc += ", " + (
(trig == Skill::Trigger::play) ? "(On Play)" :
(trig == Skill::Trigger::attacked) ? "(On Attacked)" :
(trig == Skill::Trigger::death) ? "(On Death)" :
std::string("")) + skill_names[ss.id] + skill_desc;
}
Expand Down Expand Up @@ -1116,6 +1122,15 @@ struct PerformAttack
attack_damage<def_cardtype>();
if (__builtin_expect(fd->end, false)) { return att_dmg; }
damage_dependant_pre_oa<def_cardtype>();
//APN
// resolve On-Attacked skills
for (const auto& ss: def_status->m_card->m_skills_on_attacked)
{
_DEBUG_MSG(1, "On Attacked %s: Preparing (tail) skill %s\n",
status_description(def_status).c_str(), skill_description(fd->cards, ss).c_str());
fd->skill_queue.emplace_back(def_status, ss);
resolve_skill(fd);
}

// Enemy Skill: Counter
if (def_status->has_skill(Skill::counter))
Expand Down
2 changes: 2 additions & 0 deletions sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ extern std::string card_name_by_id_safe(const Cards& cards, const unsigned card_
template<typename x_type>
inline std::string skill_description(const Cards& cards, const _SkillSpec<x_type>& s, Skill::Trigger trig)
{
//APN
return ((trig == Skill::Trigger::play) ? "(On Play)" :
(trig == Skill::Trigger::attacked) ? "(On Attacked)" :
(trig == Skill::Trigger::death) ? "(On Death)" : "") +
skill_names[s.id] +
(s.card_id == 0 ? "" : " " + card_name_by_id_safe(cards, s.card_id) + " id[" + to_string(s.card_id) + "]") +
Expand Down
2 changes: 1 addition & 1 deletion tyrant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const std::string skill_names[Skill::num_skills] =

const std::string skill_trigger_names[Skill::num_triggers] =
{
"activate", "play", "death",
"activate", "play", "attacked","death",
};

const std::string passive_bge_names[PassiveBGE::num_passive_bges] =
Expand Down
4 changes: 3 additions & 1 deletion tyrant.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TYRANT_H_INCLUDED
#define TYRANT_H_INCLUDED

#define TYRANT_OPTIMIZER_VERSION "2.54.2"
#define TYRANT_OPTIMIZER_VERSION "2.54.3"

#include <string>
#include <sstream>
Expand Down Expand Up @@ -63,6 +63,8 @@ enum Trigger
{
activate,
play,
//APN
attacked,
death,
num_triggers
};
Expand Down
8 changes: 6 additions & 2 deletions tyrant_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,12 @@ FinalResults<long double> compute_score(const EvaluatedResults& results, std::ve
final.wins += results.first[index].wins * factors[index];
final.draws += results.first[index].draws * factors[index];
final.losses += results.first[index].losses * factors[index];
auto lower_bound = boost::math::binomial_distribution<>::find_lower_bound_on_p(results.second, results.first[index].points / max_possible, 1 - confidence_level) * max_possible;
auto upper_bound = boost::math::binomial_distribution<>::find_upper_bound_on_p(results.second, results.first[index].points / max_possible, 1 - confidence_level) * max_possible;

// workaround for problem with wrong argument values: Number of Successes argument is x, but must be <= Number of Trials !
auto successes = results.first[index].points / max_possible;
successes = successes > results.second ? results.second : successes;
auto lower_bound = boost::math::binomial_distribution<>::find_lower_bound_on_p(results.second, successes, 1 - confidence_level) * max_possible;
auto upper_bound = boost::math::binomial_distribution<>::find_upper_bound_on_p(results.second, successes, 1 - confidence_level) * max_possible;
if (use_harmonic_mean)
{
final.points += factors[index] / results.first[index].points;
Expand Down
2 changes: 1 addition & 1 deletion update_xml.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
for fn in fusion_recipes_cj2 missions levels skills_set `seq -f cards_section_%g 1 13` ; do
for fn in fusion_recipes_cj2 missions levels skills_set `seq -f cards_section_%g 1 14` ; do
curl http://mobile$1.tyrantonline.com/assets/${fn}.xml -R -z data/${fn}.xml -o data/${fn}.xml
done
2 changes: 2 additions & 0 deletions xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ void parse_card_node(Cards& all_cards, Card* card, xml_node<>* card_node)
{ // inherit no skill if there is skill node
card->m_skills.clear();
card->m_skills_on_play.clear();
//APN
card->m_skills_on_attacked.clear();
card->m_skills_on_death.clear();
memset(card->m_skill_value, 0, sizeof card->m_skill_value);
memset(card->m_skill_trigger, 0, sizeof card->m_skill_trigger);
Expand Down