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

Balancing and Fight restructuring #145

Merged
merged 12 commits into from
Jun 17, 2022

Conversation

lxgr-linux
Copy link
Owner

@lxgr-linux lxgr-linux commented Jun 12, 2022

  • Add xp scaling when fighting against higher level Poketes
  • Add multiple Poketes to trainers
  • Add Fail chance to some attacks
  • Add second Poketes to some trainers
    Fixes Both i.hp <= 0 #158

This needs play testing.

@lxgr-linux lxgr-linux added the enhancement New feature or request label Jun 12, 2022
@lxgr-linux lxgr-linux requested a review from MaFeLP June 12, 2022 14:50
@lxgr-linux lxgr-linux self-assigned this Jun 12, 2022
This was linked to issues Jun 12, 2022
@lxgr-linux lxgr-linux force-pushed the 133-a-few-ideas-to-make-the-game-more-balanced branch from 8f08047 to 9667837 Compare June 14, 2022 11:46
@lxgr-linux lxgr-linux changed the title Balancing Balancing and Fight restructuring Jun 15, 2022
@lxgr-linux
Copy link
Owner Author

@daynetran

@cognivore
Copy link

How does miss chance scale as a function of defense? Or is it an intrinsic thing amplified by "cry"?

@lxgr-linux
Copy link
Owner Author

Ready for review.

@lxgr-linux
Copy link
Owner Author

How does miss chance scale as a function of defense? Or is it an intrinsic thing amplified by "cry"?

The chance of missing is influenced by the attacks and the Poketes miss chance. The Poketes misschance can be influenced by attacks like cry.

Comment on lines 302 to 308
sorted(
zip(
[i.curr.initiative for i in providers],
[1, 0],
providers
)
)[-1][-1]
Copy link
Contributor

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)

)
)[-1][-1]
)
for i in [prov.curr for prov in providers]:
Copy link
Contributor

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
    ...

Comment on lines 369 to 374
_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)
Copy link
Contributor

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

Comment on lines 39 to 46
random.choices(
list(
range(
self.arg_proto["minlvl"],
self.arg_proto["maxlvl"]
)
)
)[0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use random.choice(...)

Poke(
random.choices(
list(pokes),
weights=[i["rarity"] for _, i in pokes.items()]
Copy link
Contributor

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),
Copy link
Contributor

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?

Copy link
Owner Author

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.

Comment on lines 73 to 77
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
]:
Copy link
Contributor

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

def index_conf(self):
"""Sets index correctly"""
self.play_index = self.pokes.index(
[poke for poke in self.pokes if poke.hp > 0][0]
Copy link
Contributor

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 <mustafaq9@gmail.com>
Comment on lines 322 to 324
for prov in providers:
if prov.curr.hp <= 0:
winner = providers[(providers.index(prov) + 1) % 2]
Copy link
Contributor

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]

players, player = self.choose_poke(figure, players,
player, enemy)
if old_player == player:
loser = providers[(providers.index(winner) + 1) % 2]
Copy link
Contributor

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.

break
elif (
type(loser) is Trainer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance()

_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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance()

f"{winner.curr.ext_name} won!" +
(f'\nXP + {_xp}' if winner.curr.player else '')
)
if winner.curr.player and type(loser) is Trainer:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance()

@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not isinstance()

lxgr-linux and others added 2 commits June 17, 2022 23:16
Co-authored-by: Mustafa Quraish <mustafaq9@gmail.com>
Co-authored-by: Mustafa Quraish <mustafaq9@gmail.com>
@lxgr-linux lxgr-linux merged commit d02a06a into master Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proper PvE system Both i.hp <= 0 A few ideas to make the game more balanced
3 participants