-
Notifications
You must be signed in to change notification settings - Fork 185
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
Balancing and Fight restructuring #145
Balancing and Fight restructuring #145
Conversation
8f08047
to
9667837
Compare
How does miss chance scale as a function of defense? Or is it an intrinsic thing amplified by "cry"? |
Ready for review. |
The chance of missing is influenced by the attacks and the Poketes miss chance. The Poketes misschance can be influenced by attacks like cry. |
pokete_classes/fightmap.py
Outdated
sorted( | ||
zip( | ||
[i.curr.initiative for i in providers], | ||
[1, 0], | ||
providers | ||
) | ||
)[-1][-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max(providers, key=lambda i: i.curr.initiative)
pokete_classes/fightmap.py
Outdated
) | ||
)[-1][-1] | ||
) | ||
for i in [prov.curr for prov in providers]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to create a copy of the list here, just do:
for prov in providers:
i = prov.curr
...
pokete_classes/fightmap.py
Outdated
_xp = sum( | ||
[ | ||
poke.lose_xp + max(0, poke.lvl() - winner.curr.lvl()) | ||
for poke in loser.pokes | ||
] | ||
) * (2 if type(loser) is not NatureProvider else 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the []
around the list comprehension, sum()
can operator on generators AFAIK
pokete_classes/landscape.py
Outdated
random.choices( | ||
list( | ||
range( | ||
self.arg_proto["minlvl"], | ||
self.arg_proto["maxlvl"] | ||
) | ||
) | ||
)[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use random.choice(...)
pokete_classes/landscape.py
Outdated
Poke( | ||
random.choices( | ||
list(pokes), | ||
weights=[i["rarity"] for _, i in pokes.items()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point looping over .items()
and then ignoring the key, you're wasting tuple constructions
weights=[i["rarity"] for i in pokes.values()]
NatureProvider( | ||
Poke( | ||
random.choices( | ||
list(pokes), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a list? Can random.choices()
not handle any iterable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only takes a list.
pokete_classes/fightmap.py
Outdated
for obj in [ | ||
prov.curr.text_name, prov.curr.text_lvl, prov.curr.text_hp, | ||
prov.curr.ico, prov.curr.hp_bar, prov.curr.tril, prov.curr.trir, | ||
prov.curr.pball_small | ||
]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a tuple instead
pokete_classes/providers.py
Outdated
def index_conf(self): | ||
"""Sets index correctly""" | ||
self.play_index = self.pokes.index( | ||
[poke for poke in self.pokes if poke.hp > 0][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can instead do:
self.play_index = next(i for i, poke in enumerate(self.pokes) if poke.hp > 0)
Co-authored-by: Mustafa Quraish <[email protected]>
pokete_classes/fightmap.py
Outdated
for prov in providers: | ||
if prov.curr.hp <= 0: | ||
winner = providers[(providers.index(prov) + 1) % 2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
providers.index(prov)
takes linear time, so is this what you really want? Can you not just use:
for i, prov in enumerate(providers):
if prov.curr.hp <= 0:
winner = providers[(i + 1) % 2]
pokete_classes/fightmap.py
Outdated
players, player = self.choose_poke(figure, players, | ||
player, enemy) | ||
if old_player == player: | ||
loser = providers[(providers.index(winner) + 1) % 2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already knew the index in the block above, so why not just save that instead? That will save you having to re-look through the whole list to find the index for the object.
pokete_classes/fightmap.py
Outdated
break | ||
elif ( | ||
type(loser) is Trainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isinstance()
pokete_classes/fightmap.py
Outdated
_xp = sum( | ||
poke.lose_xp + max(0, poke.lvl() - winner.curr.lvl()) | ||
for poke in loser.pokes | ||
) * (2 if type(loser) is not NatureProvider else 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isinstance()
pokete_classes/fightmap.py
Outdated
f"{winner.curr.ext_name} won!" + | ||
(f'\nXP + {_xp}' if winner.curr.player else '') | ||
) | ||
if winner.curr.player and type(loser) is Trainer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isinstance()
pokete_classes/fightmap.py
Outdated
@@ -428,105 +439,83 @@ def throw(self, obj, enem, info, chance, name): | |||
2: The win the game | |||
None: To let the enemy attack""" | |||
|
|||
if obj.identifier == "__fallback__" or info["type"] == "duel": | |||
if type(enem) is not NatureProvider: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not isinstance()
Co-authored-by: Mustafa Quraish <[email protected]>
Co-authored-by: Mustafa Quraish <[email protected]>
Fixes Both i.hp <= 0 #158
This needs play testing.