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

pull request from myeong-ji univercity computer engineering opensource-software class project #255

Open
wants to merge 1 commit into
base: master
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
61 changes: 32 additions & 29 deletions pokete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""This software is licensed under the GPL3
You should have gotten an copy of the GPL3 license anlonside this software
You should have gotten a copy of the GPL3 license anlonside this software
Feel free to contribute what ever you want to this game
New Pokete contributions are especially welcome
For this see the comments in the definations area
Expand Down Expand Up @@ -38,9 +38,9 @@
from pokete_classes.mods import ModError, ModInfo, DummyMods
from pokete_classes.pokete_care import PoketeCare, DummyFigure
from pokete_classes import deck, detail, game, timer, ob_maps as obmp, \
movemap as mvp, fightmap as fm
movemap as mvp, fightmap as fm
# import pokete_classes.generic_map_handler as gmh
from pokete_classes.landscape import Meadow, Water, Sand, HighGrass, Poketeball
from pokete_classes.landscape import Meadow, Water, Sand, HighGrass, Poketeball, HIGHGRASS_WEIGHT
from pokete_classes.doors import CenterDoor, Door, DoorToCenter, DoorToShop, ChanceDoor
from pokete_classes.learnattack import LearnAttack
from pokete_classes.roadmap import RoadMap
Expand Down Expand Up @@ -102,7 +102,6 @@ def playmap_13_introductor(npc):
)
npc.set_used()


@staticmethod
def playmap_17_boy(npc):
"""Interaction with boy"""
Expand All @@ -111,10 +110,10 @@ def playmap_17_boy(npc):
"I've never seen one before!",
"Here you go, have $200!"])
if ask_bool(
mvp.movemap,
"The young boy gifted you $200. Do you want to accept it?",
mvp.movemap
):
mvp.movemap,
"The young boy gifted you $200. Do you want to accept it?",
mvp.movemap
):
figure.add_money(200)
npc.set_used()
else:
Expand Down Expand Up @@ -242,7 +241,8 @@ def playmap_42_npc_21(npc):
mvp.movemap,
"Do you want to give your Mowcow to the cook?", mvp.movemap
):
figure.pokes[figure.pokes.index(poke)] = Poke("__fallback__", 0)
figure.pokes[figure.pokes.index(
poke)] = Poke("__fallback__", 0)
npc.text(["Here you go, have $1000!"])
if ask_bool(
mvp.movemap,
Expand Down Expand Up @@ -327,7 +327,7 @@ def action(self, ob):


class ShopInteract(se.Object):
"""Triggers an conversation in the shop"""
"""Triggers a conversation in the shop"""

def action(self, ob):
"""Triggers an interaction in the shop
Expand Down Expand Up @@ -485,7 +485,8 @@ def add_poke(self, poke: Poke, idx=None, caught_with=None):
idx: Index of the Poke
caught_with: Name of ball which was used"""
poke.set_player(True)
poke.set_poke_stats(PokeStats(poke.name, datetime.now(), caught_with=caught_with))
poke.set_poke_stats(
PokeStats(poke.name, datetime.now(), caught_with=caught_with))
self.caught_pokes.append(poke.identifier)
if idx is None:
id_list = [i.identifier for i in self.pokes]
Expand Down Expand Up @@ -647,8 +648,7 @@ def __call__(self):
)
if not ex_cond:
break
if LearnAttack(poke, self.map, self)\
(obj.attack_name):
if LearnAttack(poke, self.map, self)(obj.attack_name):
items = self.rem_item(obj.name, items)
if len(items) == 0:
break
Expand Down Expand Up @@ -977,12 +977,13 @@ def playmap_7():
# main functions
################


def test():
"""test/demo for BetterChooseBox, until BetterChooseBox is actively used
this will remain"""
with BetterChooseBox(3, [se.Text(i, state="float") for i in ["Hallo",
"Welt", "Wie", "Gehts", "Dir", "So", "Du"]],
"Test", _map=mvp.movemap) as a:
"Welt", "Wie", "Gehts", "Dir", "So", "Du"]],
"Test", _map=mvp.movemap) as a:
while True:
action = get_action()
if action.triggers(*ACTION_DIRECTIONS):
Expand All @@ -992,7 +993,7 @@ def test():
elif action.triggers(Action.ACCEPT):
a.remove()
a.set_items(3, [se.Text(i, state="float") for i in ["test",
"test", "123", "fuckthesystem"]])
"test", "123", "fuckthesystem"]])
a.center_add(a.map)
std_loop()
a.map.show()
Expand Down Expand Up @@ -1041,11 +1042,11 @@ def swap_poke():
break
decode_data = json.loads(data.decode())
conn.sendall(
str.encode(
json.dumps(
{"mods": mods.mod_info,
"name": figure.name,
"poke": figure.pokes[index].dict()})))
str.encode(
json.dumps(
{"mods": mods.mod_info,
"name": figure.name,
"poke": figure.pokes[index].dict()})))
else:
host = ""
while host == "":
Expand All @@ -1064,10 +1065,10 @@ def swap_poke():
ask_ok(mvp.movemap, str(err), mvp.movemap)
return
sock.sendall(
str.encode(
json.dumps({"mods": mods.mod_info,
"name": figure.name,
"poke": figure.pokes[index].dict()})))
str.encode(
json.dumps({"mods": mods.mod_info,
"name": figure.name,
"poke": figure.pokes[index].dict()})))
data = sock.recv(1024)
decode_data = json.loads(data.decode())
logging.info("[Swap_poke] Recieved %s", decode_data)
Expand Down Expand Up @@ -1120,15 +1121,19 @@ def _game(_map):
}
if _map.weather is not None:
notifier.notify("Weather", "Info", _map.weather.info)
figure.fightWeight = HIGHGRASS_WEIGHT
while True:
# Directions are not being used yet
action = get_action()
if action.triggers(*ACTION_DIRECTIONS):
figure.npc = None
figure.direction = ''
figure.set(
figure.x + action.get_x_strength(),
figure.y + action.get_y_strength()
)
elif action.triggers(Action.ACCEPT) and figure.npc != None:
figure.npc.reaction()
elif action.triggers(*inp_dict):
for key, option in inp_dict.items():
if action.triggers(key):
Expand Down Expand Up @@ -1177,6 +1182,7 @@ def intro():
"Welcome to Pokete!\nPlease choose your name!\n",
"Name:", "", "Name", 17, mvp.movemap
)
figure.char = figure.name[0]
mvp.movemap.name_label_rechar(figure.name)
mvp.movemap.text(4, 3, ["Hello, my child.",
"You're now ten years old.",
Expand Down Expand Up @@ -1242,7 +1248,7 @@ def gen_obs():
single_door)
for ball, single_ball in single_map["balls"].items():
if f'{ob_map}.{ball}' not in figure.used_npcs or not \
settings("save_trainers").val:
settings("save_trainers").val:
parse_obj(_map, ball,
Poketeball(f"{ob_map}.{ball}"),
single_ball)
Expand Down Expand Up @@ -1500,7 +1506,6 @@ def map_additions():
if sys.platform == "win32":
import msvcrt


def recogniser():
"""Gets keyboard input from msvcrt, the Microsoft Visual C++ Runtime"""
while True:
Expand All @@ -1523,7 +1528,6 @@ def recogniser():
import termios
import select


def recogniser():
"""Use another (not on xserver relying) way to read keyboard input,
to make this shit work in tty or via ssh,
Expand Down Expand Up @@ -1551,7 +1555,6 @@ def recogniser():
if ord(char) == 3:
reset_terminal()


print("\033[?1049h")

# resizing screen
Expand Down
6 changes: 5 additions & 1 deletion pokete_classes/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import scrap_engine as se
import pokete_classes.game_map as gm
from release import SPEED_OF_TIME
from pokete_classes.hotkeys import get_action, Action


def transition(_map, poke):
Expand Down Expand Up @@ -61,11 +62,14 @@ def fight_intro(height, width):
if j != " ":
j.rechar(" ")
fancymap.show()
action = get_action()
if action.triggers(Action.ACCEPT):
break
time.sleep(SPEED_OF_TIME * 0.005)
for i in vec_list:
i.remove()
del fancymap


if __name__ == "__main__":
print("\033[31;1mDo not execute this!\033[0m")
print("\033[31;1mDo not execute this!\033[0m")
48 changes: 33 additions & 15 deletions pokete_classes/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def readd(self):

def remove(self):
"""Removes itself from the current pokete with a certain chance"""
logging.info("[Effect] %f rem_chance", self.rem_chance)
if random.randint(0, self.rem_chance) == 0:
self.obj.ico.map.outp.outp(f'{self.obj.ext_name} isn\'t ')
self.obj.ico.map.outp.append(se.Text(self.name,
Expand All @@ -110,6 +111,8 @@ def remove(self):
self.obj.name)
self.obj = None
time.sleep(SPEED_OF_TIME * 2)
else:
self.rem_chance //= 2

def cleanup(self, j=None):
"""Does a cleanup
Expand All @@ -127,14 +130,17 @@ def cleanup(self, j=None):

def effect(self):
"""The action that's executed every attack round"""
self.obj.ico.map.outp.outp(f'{self.obj.ext_name} is still ')
self.obj.ico.map.outp.append(se.Text(self.name,
esccode=self.str_esccode,
state="float"),
se.Text(" and can\'t attack!",
state="float"))
time.sleep(SPEED_OF_TIME * 0.5)
return 1
if random.randint(0, 1) == 0:
self.obj.ico.map.outp.outp(f'{self.obj.ext_name} is still ')
self.obj.ico.map.outp.append(se.Text(self.name,
esccode=self.str_esccode,
state="float"),
se.Text(" and can\'t attack!",
state="float"))
time.sleep(SPEED_OF_TIME * 0.5)
return 1
else:
return 0

@classmethod
def ret_md(cls):
Expand All @@ -153,7 +159,7 @@ class EffectParalyzation(Effect):
color = Color.thicc + Color.yellow

def __init__(self, obj=None):
super().__init__("paralyzed", 3, 2, "(Par)", self.color,
super().__init__("paralyzed", 6, 2, "(Par)", self.color,
obj)


Expand All @@ -163,8 +169,20 @@ class EffectSleep(Effect):
This is reverted randomly."
c_name = "sleep"
color = Color.white

def __init__(self, obj=None):
super().__init__("sleeping", 4, 3, "(Sle)", self.color, obj)
super().__init__("sleeping", 8, 3, "(Sle)", self.color, obj)

def effect(self):
"""The action that's executed every attack round"""
self.obj.ico.map.outp.outp(f'{self.obj.ext_name} is still ')
self.obj.ico.map.outp.append(se.Text(self.name,
esccode=self.str_esccode,
state="float"),
se.Text(" and can\'t attack!",
state="float"))
time.sleep(SPEED_OF_TIME * 0.5)
return 1


class EffectBurning(Effect):
Expand All @@ -175,7 +193,7 @@ class EffectBurning(Effect):
color = Color.thicc + Color.red

def __init__(self, obj=None):
super().__init__("burning", 3, 0, "(Bur)", self.color, obj,
super().__init__("burning", 6, 0, "(Bur)", self.color, obj,
exclude=["fire", "water"])
self.hurt_text = "burned it self!"
self.damage = 2
Expand Down Expand Up @@ -205,8 +223,8 @@ class EffectPoison(EffectBurning):
color = Color.purple

def __init__(self, obj=None):
super(EffectBurning, self).__init__("poisoned", 4, 2, "(Poi)", self.color
, obj)
super(EffectBurning, self).__init__(
"poisoned", 8, 2, "(Poi)", self.color, obj)
self.hurt_text = "got damaged through poison!"
self.damage = 1

Expand All @@ -218,7 +236,7 @@ class EffectConfusion(Effect):
color = Color.lightblue

def __init__(self, obj=None):
super().__init__("confused", 3, 2, "(Con)", self.color, obj,
super().__init__("confused", 6, 2, "(Con)", self.color, obj,
exclude=["undead"])

def effect(self):
Expand All @@ -239,7 +257,7 @@ class EffectFreezing(Effect):
color = Color.cyan

def __init__(self, obj=None):
super().__init__("frozen", 3, 3, "(Fro)", self.color, obj,
super().__init__("frozen", 6, 3, "(Fro)", self.color, obj,
exclude=["ice", "fire"])


Expand Down
2 changes: 1 addition & 1 deletion pokete_classes/fightmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def fight(self, providers):
audio.switch("xDeviruchi - Decisive Battle (End).mp3")
time.sleep(SPEED_OF_TIME * 1)
_xp = sum(
poke.lose_xp + max(0, poke.lvl() - winner.curr.lvl())
(int)(2 * poke.lose_xp * poke.lvl() / winner.curr.lvl())
for poke in loser.pokes
) * loser.xp_multiplier
self.outp.outp(
Expand Down
9 changes: 8 additions & 1 deletion pokete_classes/landscape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Contains classes that can be placed on playmaps"""

import random
import logging
import scrap_engine as se
import pokete_data as p_data
from pokete_classes import timer, movemap as mvp, fightmap as fm
Expand All @@ -10,6 +11,8 @@
from .poke import Poke
from .input import ask_ok

HIGHGRASS_WEIGHT = 300


class HighGrass(se.Object):
"""Object on the map, that triggers a fight"""
Expand All @@ -26,7 +29,9 @@ def action(self, ob):
if (n_a := p_data.pokes[i].get("night_active", None)) is None
or (not n_a and not is_night)
or (n_a and is_night)}
if random.randint(0, 8) == 0:
logging.info("[Walking] fight Weight %f", ob.fightWeight)
if random.randint(0, ob.fightWeight) == 0:
ob.fightWeight = HIGHGRASS_WEIGHT
fm.fightmap.fight(
[
self.figure,
Expand All @@ -47,6 +52,8 @@ def action(self, ob):
]
)
check_walk_back(self.figure)
else:
ob.fightWeight //= 2


class Meadow(se.Text):
Expand Down
Loading