-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a7cfcf
commit c47976d
Showing
9 changed files
with
160 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from .item import FightItem | ||
from .balls import PoketeBall, SuperBall, HyperBall | ||
from .healing_potions import HealingPotion, SuperPotion | ||
from .ap_potion import ApPotion | ||
|
||
fight_items: dict[str|None, FightItem] = { | ||
"heal_potion": HealingPotion(), | ||
"super_potion": SuperPotion(), | ||
"poketeball": PoketeBall(), | ||
"superball": SuperBall(), | ||
"hyperball": HyperBall(), | ||
"ap_potion": ApPotion() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import logging | ||
from pokete_classes.fight.fightmap.fightmap import FightMap | ||
from pokete_classes.fight.items.item import FightItem, RoundContinuation | ||
from pokete_classes.fight.providers import Provider | ||
|
||
|
||
class ApPotion(FightItem): | ||
def use(self, fightmap: FightMap, obj, enem: Provider) -> RoundContinuation: | ||
obj.remove_item("ap_potion") | ||
for atc in obj.curr.attack_obs: | ||
atc.set_ap(atc.max_ap) | ||
logging.info("[Fighitem][ap_potion] Used") | ||
return RoundContinuation.ENEMY_ATTACK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from abc import ABC | ||
import logging | ||
import random | ||
import time | ||
|
||
from pokete_classes.achievements import achievements | ||
from pokete_classes.fight.fightmap.fightmap import FightMap | ||
from pokete_classes.fight.providers import Provider | ||
from pokete_classes.audio import audio | ||
from ... import ob_maps as obmp | ||
from pokete_classes.fight.providers import NatureProvider, Provider | ||
from .item import FightItem, RoundContinuation | ||
from ...asset_service.service import asset_service | ||
from release import SPEED_OF_TIME | ||
|
||
|
||
class GenericPokeBall(FightItem, ABC): | ||
def __init__(self, chance:int, name: str): | ||
self.chance = chance | ||
self.name = name | ||
|
||
def use(self, fightmap: FightMap, obj, enem:Provider) -> RoundContinuation: | ||
"""Throws a ball | ||
ARGS: | ||
obj: The players Poke object | ||
enem: The enemys Poke object | ||
chance: The balls catch chance | ||
name: The balls name | ||
RETURNS: | ||
1: The continue the attack round | ||
2: The win the game | ||
None: To let the enemy attack""" | ||
if not isinstance(enem, NatureProvider): | ||
fightmap.outp.outp("You can't do that in a duel!") | ||
return RoundContinuation.CONTINUE_ATTACK | ||
fightmap.outp.rechar(f"You threw a {self.name.capitalize()}!") | ||
fightmap.fast_change( | ||
[enem.curr.ico, fightmap.deadico1, fightmap.deadico2, | ||
fightmap.pball], enem.curr.ico) | ||
time.sleep(SPEED_OF_TIME * random.choice([1, 2, 3, 4])) | ||
obj.remove_item(self.name) | ||
catch_chance = 20 if obj.map == obmp.ob_maps.get("playmap_1", None) else 0 | ||
for effect in enem.curr.effects: | ||
catch_chance += effect.catch_chance | ||
if random.choices([True, False], | ||
weights=[(enem.curr.full_hp / enem.curr.hp) | ||
* self.chance + catch_chance, | ||
enem.curr.full_hp], k=1)[0]: | ||
audio.switch("xDeviruchi - Decisive Battle (End).mp3") | ||
obj.add_poke(enem.curr, caught_with=self.name) | ||
fightmap.outp.outp(f"You caught {enem.curr.name}!") | ||
time.sleep(SPEED_OF_TIME * 2) | ||
fightmap.pball.remove() | ||
fightmap.clean_up(obj, enem) | ||
obj.balls_label_rechar() | ||
logging.info("[Fighitem][%s] Caught %s", self.name, enem.curr.name) | ||
achievements.achieve("first_poke") | ||
if all(poke in obj.caught_pokes for poke in | ||
asset_service.get_base_assets().pokes): | ||
achievements.achieve("catch_em_all") | ||
return RoundContinuation.EXIT | ||
fightmap.outp.outp("You missed!") | ||
fightmap.show() | ||
fightmap.pball.remove() | ||
enem.curr.ico.add(fightmap, enem.curr.ico.x, enem.curr.ico.y) | ||
fightmap.show() | ||
logging.info("[Fighitem][%s] Missed", self.name) | ||
return RoundContinuation.ENEMY_ATTACK | ||
|
||
class PoketeBall(GenericPokeBall): | ||
def __init__(self): | ||
super().__init__(1, "poketeball") | ||
|
||
|
||
class SuperBall(GenericPokeBall): | ||
def __init__(self): | ||
super().__init__(6, "superball") | ||
|
||
class HyperBall(GenericPokeBall): | ||
def __init__(self): | ||
super().__init__(1000, "hyperball") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from abc import ABC | ||
import logging | ||
from pokete_classes.fight.fightmap.fightmap import FightMap | ||
from pokete_classes.fight.items.item import FightItem, RoundContinuation | ||
from pokete_classes.fight.providers import Provider | ||
|
||
|
||
class GenericeHealingPotion(FightItem, ABC): | ||
def __init__(self, hp: int, name: str): | ||
self.hp = hp | ||
self.name = name | ||
|
||
def use(self, fightmap: FightMap, obj, enem: Provider) -> RoundContinuation: | ||
obj.remove_item(self.name) | ||
obj.curr.oldhp = obj.curr.hp | ||
obj.curr.hp = min(obj.curr.full_hp, obj.curr.hp + self.hp) | ||
obj.curr.hp_bar.update(obj.curr.oldhp) | ||
logging.info("[Fighitem][%s] Used", self.name) | ||
return RoundContinuation.ENEMY_ATTACK | ||
|
||
class HealingPotion(GenericeHealingPotion): | ||
def __init__(self): | ||
super().__init__(5, "healing_potion") | ||
|
||
class SuperPotion(GenericeHealingPotion): | ||
def __init__(self): | ||
super().__init__(15, "super_potion") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from abc import ABC, abstractmethod | ||
from enum import Enum, auto | ||
|
||
from pokete_classes.fight.fightmap.fightmap import FightMap | ||
from pokete_classes.fight.providers import Provider | ||
|
||
|
||
class RoundContinuation(Enum): | ||
CONTINUE_ATTACK = auto() | ||
EXIT = auto() | ||
ENEMY_ATTACK = auto() | ||
|
||
|
||
class FightItem(ABC): | ||
|
||
@abstractmethod | ||
def use(self, fightmap: FightMap, obj, enem:Provider) -> RoundContinuation: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters