From 485022e73c9a14a6c6872ef337a6c56d3b9e6016 Mon Sep 17 00:00:00 2001 From: Mart van de Ven Date: Sun, 12 Jun 2016 14:05:49 +0800 Subject: [PATCH] Targaryan House ability --- S06/core/house.py | 31 ++++++++++++++---- S06/core/intelligence.py | 12 ++++++- S06/core/league.py | 2 +- S06/fix-character-health.ipynb | 60 ++++++++++++---------------------- 4 files changed, 57 insertions(+), 48 deletions(-) diff --git a/S06/core/house.py b/S06/core/house.py index fb48d2f..b11640d 100644 --- a/S06/core/house.py +++ b/S06/core/house.py @@ -943,11 +943,32 @@ def is_dothraki(self, league, agent): assassin = league.game.characters[agent] return 'Dothraki' in assassin.bio - def bonus_mission(self, league, mission, target_house, target_house_name, target_roster): + def bonus_mission(self, league, mission): # TODO TARGARYEN ABILITY: # All Characters on this House’s Roster gain + target_house = mission['data']['target_house'] + target_house_name = league.get_house(mission['data']['target_house']).full_name + + healths = league.get_house_player(self.name).character_health + + + # + + for char, health in healths.iteritems(): + if health > 0: + healths[char] += 5 + + key = "{}{}{}".format(self.name, self.name, league.current_episode) + + league.game.set_character_health(key, { + "episode" : league.current_episode, + "house" : self.name, + "health" : healths + }) + + # 5% Bonus on a succesful attack by a Dothraki Character print 'WARNING >>> TARGARYEN NEEDS HOUSE ABILITY' @@ -957,12 +978,8 @@ def spread_the_word(self, league, mission): mission = self.reveal_outgoing_missions(league, mission) if mission['type'] == 'assassination' and mission['success'] and self.is_dothraki(league, mission['data']['agent']): - - target_house = mission['data']['target_house'] - target_house_name = league.get_house(mission['data']['target_house']).full_name - target_roster = league.get_house(mission['data']['target_house']).character_health - - self.bonus_mission(league, mission, target_house, target_house_name, target_roster) + + self.bonus_mission(league, mission) target_player = league.get_house_player(mission['data']['target_house']) target_player.house.reveal_incoming_missions(league, mission, self.name) diff --git a/S06/core/intelligence.py b/S06/core/intelligence.py index 518d6db..6be2520 100644 --- a/S06/core/intelligence.py +++ b/S06/core/intelligence.py @@ -309,7 +309,7 @@ def _random_selector(self): intel = self.get_intel_template() - while True: + for i in range(10000): intel['code'], intel['message'] = random.choice(self.intel_types)() @@ -319,6 +319,16 @@ def _random_selector(self): self.intelligence_events.append(intel) return intel + + # No valid intel after 1000 attempts at generating them + + intel = self.get_intel_template() + + intel['code'] = 'C|DEPLETED' + intel['message'] = "This character has no secrets left... " + + return intel + def get_target_character_code(self): char = self.target_character_id diff --git a/S06/core/league.py b/S06/core/league.py index c0132e7..5fb2521 100644 --- a/S06/core/league.py +++ b/S06/core/league.py @@ -163,7 +163,7 @@ def process_episode_results(self, votes=True, missions=False, analytics=True): if missions: # DEVELOPER self.run_weekly_diplomatic_missions() - # print '*** DIPLOMATIC MISSIONS RUN ***' + print '*** DIPLOMATIC MISSIONS RUN ***' # DEVELOPER self.run_weekly_assassion_missions() print '*** ASSASSINATION MISSIONS RUN ***' diff --git a/S06/fix-character-health.ipynb b/S06/fix-character-health.ipynb index db6e772..f8e5f7e 100644 --- a/S06/fix-character-health.ipynb +++ b/S06/fix-character-health.ipynb @@ -4,7 +4,7 @@ "cell_type": "code", "execution_count": 1, "metadata": { - "collapsed": true + "collapsed": false }, "outputs": [], "source": [ @@ -20,40 +20,40 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "base[u'character_health'] = {k:v for k,v in base[u'character_health'].iteritems() if v['episode'] < 55}" + "base[u'character_health'] = {k:v for k,v in base[u'character_health'].iteritems() if v['episode'] < 57}" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "missions = {k:v for k,v in base[u'missions'].iteritems() if v['episode'] == '54'}" + "missions = {k:v for k,v in base[u'missions'].iteritems() if v['episode'] == '56'}" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "character_health = {k:v for k,v in base[u'character_health'].iteritems() if v['episode'] == 54}" + "character_health = {k:v for k,v in base[u'character_health'].iteritems() if v['episode'] == 56}" ] }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 5, "metadata": { "collapsed": true }, @@ -64,7 +64,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 6, "metadata": { "collapsed": false }, @@ -73,19 +73,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "100\n", - "daenerystargaryen\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", - "0\n", - "tyrionlannister\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", - "100\n", - "daenerystargaryen\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", "FAIL\n", @@ -109,27 +103,19 @@ "FAIL\n", "\n", "\n", - "100\n", - "brienneoftarth\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", - "100\n", - "aryastark\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", - "0\n", - "aryastark\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", "FAIL\n", "\n", "\n", - "100\n", - "tyrionlannister\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", "FAIL\n", @@ -138,14 +124,10 @@ "FAIL\n", "\n", "\n", - "100\n", - "wunwun\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n", - "100\n", - "jaqenhghar\n", - "SUCCESS\n", + "FAIL\n", "\n", "\n" ] @@ -158,7 +140,7 @@ " l = m['league']\n", " d = base['characters'][m['assassination_agent']]['violence']\n", " try:\n", - " v = base[u'character_health'][l+h+'54']['health']\n", + " v = base[u'character_health'][l+h+'56']['health']\n", " print v[m['assassination_target_character']]\n", " print m['assassination_target_character']\n", " v[m['assassination_target_character']] = max(v[m['assassination_target_character']] - damage[d], 0)\n", @@ -171,7 +153,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 7, "metadata": { "collapsed": false, "scrolled": false @@ -183,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 8, "metadata": { "collapsed": false },