/usr/lib/games/solarwolf/players.py is in solarwolf 1.5-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | #player data... wooo
#each player needs a name, guid, score
#high score list has name, guid, score
import time, random, sys, game, pickle, tempfile
import os
players = []
winners = []
def new_guid():
return str(random.randint(0, sys.maxint-1))
def make_winner(player):
player.winner = 1
players.remove(player)
winners.insert(0, player)
game.player = None
class Player:
def __init__(self, name, guid=None, score=0):
self.name = name
self.score = score
self.skips = 0
self.winner = 0
self.lives = 0
self.cheater = 0
self.help = {}
if guid:
self.guid = guid
else:
self.newguid()
def __str__(self):
vals = self.name, self.guid, self.score
return 'Player(%s, %s, %d)' % vals
def newguid(self):
self.guid = self.name + '_' + new_guid()
def start_level(self):
if not self or self.score < 1:
return 0
return self.score
def find_player(guid):
for p in players:
if p.guid == guid:
return p
return None
def load_players():
global players, winners
allplayers = []
players = []
winners = []
try:
filename = game.make_dataname('players')
allplayers = pickle.load(open(filename, 'rb'))
for p in allplayers:
if p.winner:
winners.append(p)
if not hasattr(p, "lives"):
p.lives = 0
if not hasattr(p, "skips"):
p.skips = 0
if not hasattr(p, "cheater"):
p.cheater = 0
else:
players.append(p)
if not hasattr(p, "help"):
p.help = {}
if not hasattr(p, "lives"):
p.lives = p.score * 2
if not hasattr(p, "skips"):
p.skips = 0
if not hasattr(p, "cheater"):
p.cheater = 0
except (IOError, OSError, KeyError, IndexError):
players = []
#print 'ERROR OPENING PLAYER FILE'
def save_players():
allplayers = players + winners
try:
filename = game.make_dataname('players')
f = open(filename, 'wb')
p = pickle.Pickler(f, 1)
p.dump(allplayers)
f.close()
except (IOError, OSError), msg:
import messagebox
messagebox.error("Error Saving Player Data",
"There was an error saving the player data.\nCurrent player data has been lost.\n\n%s"%msg)
|