Skip to content

Commit

Permalink
#267 Fixed saving
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed May 9, 2023
1 parent 3b1dc7c commit b862d10
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
16 changes: 12 additions & 4 deletions pokete.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pokete_classes.map_additions.map_addtions import map_additions
import pokete_classes.multiplayer.connector as connector
from pokete_classes.multiplayer.menu import ModeChooser
from pokete_classes.multiplayer.modeprovider import modeProvider, Mode
from pokete_classes.pokestats import PokeStats
from pokete_classes.poke import Poke, upgrade_by_one_lvl
from pokete_classes.color import Color
Expand Down Expand Up @@ -718,15 +719,22 @@ def autosave():

def save():
"""Saves all relevant data to savefile"""
_map = figure.map.name
old_map = figure.oldmap.name
x = figure.x
y = figure.y
if modeProvider.mode == Mode.MULTI:
_map, old_map, x, y = connector.connector.saved_pos

_si = {
"user": figure.name,
"represent_char": figure.char,
"ver": VERSION,
"map": figure.map.name,
"oldmap": figure.oldmap.name,
"map": _map,
"oldmap": old_map,
"last_center_map": figure.last_center_map.name,
"x": figure.x,
"y": figure.y,
"x": x,
"y": y,
"achievements": achievements.achieved,
"pokes": {i: poke.dict() for i, poke in enumerate(figure.pokes)},
"inv": figure.inv,
Expand Down
7 changes: 7 additions & 0 deletions pokete_classes/multiplayer/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self):
self.map = None
self.overview = None
self.figure = None
self.saved_pos = ()

def __call__(self, _map, overview):
self.map = _map
Expand Down Expand Up @@ -99,6 +100,12 @@ def handshake(self):
self.figure,
)
pos = d["Body"]["Position"]
self.saved_pos = (
self.figure.map.name,
self.figure.oldmap.name,
self.figure.x,
self.figure.y,
)
self.figure.remove()
self.figure.add(
obmp.ob_maps[pos["Map"]], pos["X"], pos["Y"]
Expand Down
2 changes: 1 addition & 1 deletion pokete_classes/multiplayer/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def __call__(self):
modeProvider.mode = Mode.SINGLE
return
elif num == 1:
modeProvider.mode = Mode.MULTI
connector.connector(self.map, self)
modeProvider.mode = Mode.MULTI
return
else:
sys.exit()
Expand Down
4 changes: 2 additions & 2 deletions pokete_classes/multiplayer/modeprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


class Mode(Enum):
SINGLE = auto
MULTI = auto
SINGLE = auto()
MULTI = auto()


class ModeProvider:
Expand Down

0 comments on commit b862d10

Please sign in to comment.