Browse Source

initial commit

master
b3yond 5 years ago
commit
d364df1911
  1. 41
      README.md
  2. 0
      code/__init__.py
  3. 180
      code/augmentations.py
  4. 858
      code/editor.py
  5. 218
      code/enemies.py
  6. 1298
      code/game.py
  7. 304
      code/items.py
  8. 579
      code/old_functions.py
  9. BIN
      images/augmentations/artificial_leg.gif
  10. BIN
      images/augmentations/blessed_by_luck.gif
  11. BIN
      images/augmentations/cosmetic_surgery.gif
  12. BIN
      images/augmentations/eye_processor.gif
  13. BIN
      images/augmentations/fear_blocker.gif
  14. BIN
      images/augmentations/genetic_surgery.gif
  15. BIN
      images/augmentations/kevlar_implant.gif
  16. BIN
      images/augmentations/learning_software.gif
  17. BIN
      images/augmentations/reflex_chip.gif
  18. BIN
      images/augmentations/wallhack.gif
  19. BIN
      images/characters/1one.gif
  20. BIN
      images/characters/2two.gif
  21. BIN
      images/characters/3three.gif
  22. BIN
      images/characters/4four.gif
  23. BIN
      images/characters/5five.gif
  24. BIN
      images/characters/6six.gif
  25. BIN
      images/characters/7seven.gif
  26. BIN
      images/characters/8eight.gif
  27. BIN
      images/characters/9nine.gif
  28. BIN
      images/characters/angel.gif
  29. BIN
      images/characters/player.gif
  30. BIN
      images/characters/vampire.gif
  31. BIN
      images/characters/werewolf.gif
  32. BIN
      images/charwinexample.gif
  33. BIN
      images/charwinexample.xcf
  34. BIN
      images/fields/0leer.gif
  35. BIN
      images/fields/barricada.gif
  36. BIN
      images/fields/door.gif
  37. BIN
      images/fields/loot.gif
  38. BIN
      images/fields/treasure.gif
  39. BIN
      images/fields/wall.gif
  40. BIN
      images/guns/glock.gif
  41. BIN
      images/guns/kalaschnikow.gif
  42. BIN
      images/guns/lmg.gif
  43. BIN
      images/guns/m4carbine.gif
  44. BIN
      images/guns/p90.gif
  45. BIN
      images/guns/sawnoff.gif
  46. BIN
      images/guns/shotgun.gif
  47. BIN
      images/guns/sniper.gif
  48. BIN
      images/guns/uzi.gif
  49. BIN
      images/kreis.gif
  50. BIN
      images/panels/charwinbackground.gif
  51. BIN
      images/panels/consolebackground.gif
  52. BIN
      images/panels/emptyfields.gif
  53. BIN
      images/panels/inventorybackground.gif
  54. BIN
      images/panels/midpanel.gif
  55. BIN
      images/panels/sidepanel.gif
  56. BIN
      images/panels/spellpanel.gif
  57. BIN
      images/panels/textpanel.gif
  58. BIN
      images/panels2/augframe.gif
  59. BIN
      images/panels2/backbutton.gif
  60. BIN
      images/panels2/charwinbackground.gif
  61. BIN
      images/panels2/consolebackground.gif
  62. BIN
      images/panels2/emptyfields.gif
  63. BIN
      images/panels2/highpanel.gif
  64. BIN
      images/panels2/inventorybackground.gif
  65. BIN
      images/panels2/leftpanel.gif
  66. BIN
      images/panels2/rightmidpanel.gif
  67. BIN
      images/panels2/spellbutton.gif
  68. BIN
      images/panels2/textpanel.gif
  69. BIN
      images/races/Angel.gif
  70. BIN
      images/races/Golem.gif
  71. BIN
      images/races/Vampire.gif
  72. BIN
      images/races/Werewolf.gif
  73. BIN
      images/swords/baton.gif
  74. BIN
      images/swords/claws.gif
  75. BIN
      images/swords/claymore.gif
  76. BIN
      images/swords/katana.gif
  77. BIN
      images/swords/knife.gif
  78. BIN
      images/swords/longsword.gif
  79. BIN
      images/swords/mace.gif
  80. BIN
      images/swords/nunchaku.gif
  81. BIN
      images/swords/shortsword.gif
  82. BIN
      images/swords/silverclaws.gif
  83. BIN
      images/swords/silverdagger.gif
  84. BIN
      images/swords/silversword.gif
  85. BIN
      images/swords/whip.gif
  86. 1661
      missions/H14
  87. 1298
      missions/Sewers
  88. 688
      missions/test
  89. 97
      notes/Magic.txt
  90. 462
      notes/Notizen.txt
  91. 309
      resources/enemies
  92. 83
      resources/guns
  93. 134
      resources/swords

41
README.md

@ -0,0 +1,41 @@
# Treasure Hunting
Treasure Hunting is supposed to be a small game.
Originally it was played in school by a few bored teenagers, with pen and paper - but we want to bring it on screen!
This is actually the 5th edition of Treasure Hunting, but the second to be realized digitally.
A new version was started, because this one will be in python2.
It is not yet decided, which engine will be used.
# About
In the world of Treasure Hunting, vampires, werewolves, angels, and several other supernatural entities (SUPs) were living among humans undetected.
Since their detection through a recommended scientist with peaceful intentions, their status is complicated.
Racist groups are afraid of them and convinced most states to hunt SUPs down and kill them all.
But that is not the fate of most SUPs - usually they are used by corporations and other militant groups as effective mercenaries or for research purposes.
You are playing one of these soldiers, and are deciding their fate in a world full of corporate interests, racist hostilities and violence.
# Contents
This is a new approach, so not all old data and mechanics are used. For these, visit https://github.com/compl4xx/TreasureHunting
There is this data:
notes: these are text files which explain the game and define some of its core mechanics and game data.
- Notizen.txt: Game mechanics, to do list, function flow stuff.
- Magic.txt: Concept of the magic language.
code: here is the folder for the .py files.
- \_\_init.py\_\_: empty but important file.
- game.py: main code file. here is the game flow.
- items.py: file for the item object data.
- enemies.py: file for the enemy object data.
- augmentations.py: file for the augmentation functions.
- editor.py: program to create missions, items, enemies.
images: here are all of the game graphics.
- characters: graphics of humanoid characters
- fields: graphics of surroundings
- guns, swords: item graphics
- panels: old panel graphics (750x300 window
- panels2: current panel graphics (800x600 window)
- races: race logos
missions: mission files
saves: save files
resources: here are enemies, guns and swords saved.

0
code/__init__.py

180
code/augmentations.py

@ -0,0 +1,180 @@
#! /usr/bin/env python
# Augmentations
# All of them cost 100 BTC?
# only 3 of them at the same time
# I think there is a dictionary needed to connect the strings to images, and maybe prices.
# most augmentation effects are checked in other functions.
from random import randint
def augment(char, aug, m):
""" add an augmentation to character.
When a Character gets an augmentation, its name is put in the
char.augmentations-list. if it has a static effect on char values,
they are also changed in this function. every other effects are
checked in other functions.
:param char: object
:param aug: string
:param m: SDLInstanceManager object
:return: char: object
"""
if aug in char.augmentations:
m.console.push("ERROR: Character already has " + aug + ".")
elif len(char.augmentations) > 4:
m.console.push("ERROR: Character has already 3 augmentations")
else:
if "cosmetic surgery" in char.augmentations:
cost = 90
else:
cost = 100
if char.bitcoins < cost:
m.console.push("ERROR: Not enough bitcoins!")
return char
else:
char.bitcoins -= cost
if randint(0, 99) > 10:
if aug == "genetic surgery":
char.morph = True
elif aug == "eye processor":
char.agi += 2
elif aug == "artificial leg":
char.mob += 2
char.augmentations.append(aug)
m.console.push("The surgery went well.")
else:
char.con -= 1
m.console.push("The surgery failed. You lose 1 Consitution.")
m.charwin.process()
return char
def deaugment(char, aug, m):
""" erase an augmentation from character.
first destroys values, if they had been changed by augmentation, then
deletes name from char.augmentations
:param char: object
:param aug: string
:param m: SDLInstanceManager object
:return: char: object
"""
if aug not in char.augmentations:
m.console.push("ERROR: Character doesn't have " + aug + ".")
else:
if aug == "genetic surgery":
char.morph = False
elif aug == "eye processor":
char.agi -= 2
elif aug == "artificial leg":
char.mob -= 2
char.augmentations.remove(aug) # does this work? aug is not in
# augmentations asd
if randint(0, 99) > 10:
m.console.push(aug + " has been removed successfully.")
m.charwin.process()
else:
char.con -= 1
m.console.push("The surgery failed. You lose 1 Consitution.")
return char
all_augmentations = {
"artificial leg": "../images/augmentations/artificial_leg.gif",
"reflex chip": "../images/augmentations/reflex_chip.gif",
"kevlar implant": "../images/augmentations/kevlar_implant.gif",
"eye processor": "../images/augmentations/eye_processor.gif",
"cosmetic surgery": "../images/augmentations/cosmetic_surgery.gif",
"fear blocker": "../images/augmentations/fear_blocker.gif",
"wallhack": "../images/augmentations/wallhack.gif",
"genetic surgery": "../images/augmentations/genetic_surgery.gif",
"learning software": "../images/augmentations/learning_software.gif",
"blessed by luck": "../images/augmentations/blessed_by_luck.gif"
}
# What other augmentations are there, and what do they do?
'''
def artificial_leg(char):
# mobility + 2
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("artificial leg")
char.mob += 2
def reflex_chip(char):
# 10 % Chance each turn, that IC is reduced by 10, checked at turn function
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("reflex chip")
def kevlar_implant(char):
# +20 max_HP, check at update_maxHP()
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("kevlar implant")
def eye_processor(char):
# agility + 2
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("eye processor")
char.agi += 2
def cosmetic_surgery(char):
# all costs -10 BTC, checked at buy function
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("cosmetic surgery")
def fear_blocker(char):
# Use guns in melee, checked at act function
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("fear blocker")
def wallhack(char):
# No hitting malus because of barricades
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("wallhack")
def genetic_surgery(char):
# Player can morph into a werewolf: double stats, dont use weapons while morphed
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
elif char.morph:
print("ERROR: player can already turn into a werewolf")
else:
char.augmentations.append("genetic surgery")
char.morph = True
def learning_software(char):
# needed XP per level: -15, checked at levelup function
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("learning software")
def blessed_by_luck(char):
# chance tests += 0.05, checked at chance function?
if char.augmentations.length > 4:
print("ERROR: already 3 augmentations")
else:
char.augmentations.append("blessed by luck")
'''

858
code/editor.py

@ -0,0 +1,858 @@
#! /usr/bin/env python
# coding=utf-8
#
#
# contents:
# 1. Imports
# 2. Globals
# 3. Classes
# 4.
# # # # # # #
# 1.Imports #
# # # # # # #
import pickle
import pygtk
import game
import os
from enemies import *
from items import *
pygtk.require("2.0")
import gtk
# # # # # # #
# 2.Globals #
# # # # # # #
# # # # # # #
# 3.Classes #
# # # # # # #
class RoomEditor(object):
""" Room Editor window class.
Window contains a List of choosable fields on the right, the modifiable fields on the left,
and can give certain fields other values, which go into Room.fielddata
or it does when its ready >.<
weird bug: Save&Quit doesnt close the window, but still returns a room object.
"""
def __init__(self):
self.chosen = "W"
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(10)
self.box2 = gtk.HBox(False, 0)
self.menubox = gtk.VBox(False, 0)
# initialise list of lists: fields, later argument to Room()
self.fields = []
for i in range(30):
self.fields.append([])
for j in range(52):
self.fields[i].append("O")
# initialize dictionary: fielddata, later argument to Room()
self.fielddata = {}
self.show_fields()
# List which contains the buttons to choose field types
self.choose_buttons = []
self.choose_buttons.append(self.add_button(i_wall(), self.choose_field,
box=self.menubox, arg="W"))
self.choose_buttons.append(self.add_button(i_leer(), self.choose_field,
box=self.menubox, arg="O"))
self.choose_buttons.append(self.add_button(i_barricada(), self.choose_field,
box=self.menubox, arg="B"))
self.choose_buttons.append(self.add_button(i_treasure(), self.choose_field,
box=self.menubox, arg="T"))
self.choose_buttons.append(self.add_button(i_player(), self.choose_field,
box=self.menubox, arg=0))
self.choose_buttons.append(self.add_button(i_1one(), self.choose_field,
box=self.menubox, arg=1))
self.choose_buttons.append(self.add_text_button("Give Option", self.choose_field,
box=self.menubox, arg="C"))
self.choose_buttons.append(self.add_text_button("Save & Quit", self.savequit,
box=self.menubox))
self.window.add(self.box2)
self.box2.pack_end(self.menubox) # Vertical Box, for choosing Buttons
self.menubox.show()
self.box2.show()
self.window.unmaximize()
self.window.show()
def main(self):
gtk.main() # starting event processing loop
def delete_event(self, widget, event, data=None):
"""
:return False if you want to destroy window
:return True if you want to keep window
"""
print "[Gtk] delete event occured"
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def add_button(self, image, function, box=0, arg=None):
self.button = gtk.Button()
# When the button is clicked it calls self.hello()
self.button.connect("clicked", function, arg)
self.button.add(image)
# pack a box to the beginning.
if box:
box.pack_start(self.button, True, True, 0)
# Close the window
# uncomment this if you want to close all parent windows without other children
# when you close a window.
# self.button1.connect_object("clicked", gtk.Widget.destroy, self.window)
self.button.show()
return self.button
def add_text_button(self, label, function, box=0, arg=None):
self.button = gtk.Button(label)
self.button.connect("clicked", function, arg)
if box:
box.pack_start(self.button, True, True, 0)
self.button.show()
return self.button
def choose_field(self, unusedbutnecessary, arg):
""" choose, which field you want to add to Room.fields
:param arg: string/integer of field type which is chosen to be added to fields.
"""
self.chosen = arg
def show_fields(self):
""" shows the current fields.
:param fields: list of lists
:return:
"""
y = len(self.fields)
x = len(self.fields[0])
self.table = gtk.Table(x, y)
self.buttonlist = []
for i in range(y):
self.buttonlist.append([])
for j in range(x):
a = (i, j)
a = self.add_button(self.which_image(self.fields[i][j]),
self.change_field, arg=a)
self.buttonlist[i].append(a)
self.table.attach(a, j, j + 1, i, i + 1)
a.show()
self.box2.pack_start(self.table)
self.table.show()
def change_field(self, unusedbutnecessary, xy):
if self.chosen == "C":
self.give_option()
return
i = xy[0]
j = xy[1]
self.fields[i][j] = self.chosen
self.buttonlist[i][j].destroy()
a = self.add_button(self.which_image(self.fields[i][j]), self.change_field, arg=xy)
self.buttonlist[i][j] = a
self.table.attach(a, j, j + 1, i, i + 1)
a.show()
self.table.show()
self.box2.show()
self.window.show()
def which_image(self, arg):
if arg == "W":
return i_wall()
elif arg == "O":
return i_leer()
elif arg == "B":
return i_barricada()
elif arg == "T":
return i_treasure()
elif arg == 0:
return i_player()
elif arg == 1:
return i_1one()
def give_option(self, unusedbutnecessary, xy):
""" Dialog to add entries to fielddata.
This is executed if the give_option is chosen and a field is clicked.
The field type is then assigned a value, e.g:
{
1 : "Police Officer", (enemy[0])
2 : 15413874260947 (Room.description)
}
for now I can't implement Doors, as there is no way to edit Rooms.
enemies: list of lists
Do I need this function? maybe I should do this with CLI.
:param unusedbutnecessary: unused
:param xy: tuple(x,y), self.fields[x][y]
:return:
"""
# dialog
# Lots of Buttons to choose from:
# for room in rooms: room.id
# for enemy in enemies: enemy[0]
# fielddata.remove(entry)
# fielddata[entry] = choice
# dialog = gtk.Dialog(title="Enter a description", parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=None)
with open("../resources/enemies", "r+") as file:
enemies = pickle.load(file)
def savequit(self, unusedbutnecessary, unusedbutnecessary2):
dialog = gtk.Dialog(title="Enter a description", parent=self.window,
flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=None)
entry = gtk.Entry()
dialog.action_area.pack_start(entry)
entry.show()
button = gtk.Button("Ok")
button.connect("clicked", self.getext, entry)
button.connect("clicked", dialog.destroy)
dialog.action_area.pack_start(button)
button.show()
dialog.action_area.show()
dialog.show()
def getext(self, unusedbutnecessary, widget):
description = widget.get_text()
widget.destroy()
self.room = game.Room(self.fields, self.fielddata, description)
self.window.destroy()
class Choose_Field_Window(object):
""" Window for choosing one field of the mission.
weird bug: Save&Quit doesnt close the window, but still returns the coordinates.
"""
def __init__(self, room):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(10)
self.box1 = gtk.HBox()
self.room = room
self.show_fields()
self.window.add(self.box1)
self.box1.show()
self.window.show()
def main(self):
gtk.main() # starting event processing loop
return self.arg
def delete_event(self, widget, event, data=None):
"""
:return False if you want to destroy window
:return True if you want to keep window
"""
print "[Gtk] delete event occured"
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def show_fields(self):
""" shows the current fields.
:param fields: list of lists
:return:
"""
y = len(self.room.fields)
x = len(self.room.fields[0])
self.table = gtk.Table(x, y)
self.buttonlist = []
for i in range(y):
self.buttonlist.append([])
for j in range(x):
a = (i, j)
a = self.add_button(self.which_image(self.room.fields[i][j]), self.choose_field, arg=a)
self.buttonlist[i].append(a)
self.table.attach(a, j, j + 1, i, i + 1)
a.show()
self.box1.pack_start(self.table)
self.table.show()
def which_image(self, arg):
if arg == "W":
return i_wall()
elif arg == "O":
return i_leer()
elif arg == "B":
return i_barricada()
elif arg == "T":
return i_treasure()
elif arg == 0:
return i_player()
elif arg == 1:
return i_1one()
def add_button(self, image, function, box=0, arg=None):
self.button = gtk.Button()
self.button.add(image)
# When the button is clicked it calls self.hello()
self.button.connect("clicked", function, arg)
# pack a box to the beginning.
if box:
box.pack_start(self.button, True, True, 0)
# Close the window
# uncomment this if you want to close all parent windows without other children
# when you close a window.
# self.button1.connect_object("clicked", gtk.Widget.destroy, self.window)
self.button.show()
return self.button
def choose_field(self, unusedbutnecessary, arg):
self.arg = arg
self.window.destroy()
class CreateEnemyWin(object):
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(20)
global filename
filename = "../images/1one.gif" # default value
self.box1 = gtk.VBox()
self.table1()
self.button = gtk.Button("Done")
self.button.connect("clicked", self.get_values)
self.button.connect("clicked", self.destroy)
self.box1.pack_start(self.button)
self.button.show()
self.window.add(self.box1)
self.box1.show()
self.window.show()
def main(self):
gtk.main() # starting event processing loop
return self.output
def delete_event(self, widget, event, data=None):
"""
:return False if you want to destroy window
:return True if you want to keep window
"""
print "[Gtk] delete event occured"
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def table1(self):
self.table = gtk.Table(2, 13)
self.tablelabel("Name:", 0)
self.tablelabel("Race:", 1)
self.tablelabel("Image:", 2)
self.tablelabel("Constitution:", 3)
self.tablelabel("Strength:", 4)
self.tablelabel("Agility:", 5)
self.tablelabel("Mobility:", 6)
self.tablelabel("Intelligence:", 7)
self.tablelabel("Gun:", 8)
self.tablelabel("Sword:", 9)
self.tablelabel("Min. Loot:", 10)
self.tablelabel("Max. Loot:", 11)
self.tablelabel("Experience", 12)
self.inputs = []
self.tableobject(gtk.Entry, 0)
self.tableobject(gtk.Entry, 1)
self.button = gtk.Button("Choose File")
self.button.connect("clicked", self.choose_file)
self.table.attach(self.button, 1, 2, 2, 3)
self.button.show()
self.tableobject(gtk.Entry, 3)
self.tableobject(gtk.Entry, 4)
self.tableobject(gtk.Entry, 5)
self.tableobject(gtk.Entry, 6)
self.tableobject(gtk.Entry, 7)
self.tableobject(gtk.Entry, 8)
self.tableobject(gtk.Entry, 9)
self.tableobject(gtk.Entry, 10)
self.tableobject(gtk.Entry, 11)
self.tableobject(gtk.Entry, 12)
self.box1.pack_start(self.table)
self.table.show()
def tablelabel(self, title, y):
a = gtk.Label(title)
self.table.attach(a, 0, 1, y, y + 1)
a.show()
def tableobject(self, Klass, y):
a = Klass()
self.inputs.append(a)
self.table.attach(a, 1, 2, y, y + 1)
a.show()
def get_values(self, unusedbutnecessary):
lst = []
end = []
for a in self.inputs:
lst.append(a.get_text())
for i in range(len(lst) + 1):
if i == 2:
end.append(self.filename)
end.append(i)
self.output = {lst[0]: lst}
def choose_file(self, unusedbutnecessary):
self.filesel = gtk.FileSelection("Select an image")
self.filesel.ok_button.connect("clicked", lambda w: self.file_ok_sel)
self.filesel.ok_button.connect("clicked", lambda w: self.filesel.destroy())
self.filesel.cancel_button.connect("clicked", lambda w: self.filesel.destroy())
self.filesel.set_filename("../images/characters/1one.gif")
self.filesel.show()
def file_ok_sel(self, w):
global filename
filename = self.filesel.get_filename()
class CreateGunWin(object):
""" Window to create guns classes.
To do: design gun logos and change the default values.
def __init__(self, name, price, image, damage, grange, ap):
super(Gun, self).__init__(name, price, image)
self.damage = damage # Integer
self.grange = grange # Integer
self.ap = ap # Integer, AP needed to fire the gun
self.type = "gun"
"""
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(20)
self.filename = "../images/guns/glock.gif" # default value
self.box1 = gtk.VBox()
self.table1()
self.button = gtk.Button("Done")
self.button.connect("clicked", self.get_values)
self.button.connect("clicked", self.destroy)
self.box1.pack_start(self.button)
self.button.show()
self.window.add(self.box1)
self.box1.show()
self.window.show()
def main(self):
gtk.main() # starting event processing loop
return self.output
def delete_event(self, widget, event, data=None):
"""
:return False if you want to destroy window
:return True if you want to keep window
"""
print "[Gtk] delete event occured"
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def table1(self):
self.table = gtk.Table(2, 13)
self.tablelabel("Name:", 0)
self.tablelabel("Price:", 1)
self.tablelabel("Damage:", 2)
self.tablelabel("Range:", 3)
self.tablelabel("AP:", 4)
self.tablelabel("Image:", 5)
self.inputs = []
for i in range(0, 5):
self.tableobject(gtk.Entry, i)
self.button = gtk.Button("Choose File")
self.button.connect("clicked", self.choose_file)
self.table.attach(self.button, 1, 2, 5, 6)
self.button.show()
self.box1.pack_start(self.table)
self.table.show()
def tablelabel(self, title, y):
a = gtk.Label(title)
self.table.attach(a, 0, 1, y, y + 1)
a.show()
def tableobject(self, Klass, y):
a = Klass()
self.inputs.append(a)
self.table.attach(a, 1, 2, y, y + 1)
a.show()
def get_values(self, unusedbutnecessary):
lst = []
end = []
for a in self.inputs:
lst.append(a.get_text())
for i in range(len(lst) + 1):
if i == 2:
end.append(self.filename)
end.append(i)
self.output = {lst[0]: lst}
def choose_file(self, unusedbutnecessary):
self.filesel = gtk.FileSelection("Select an image")
self.filesel.ok_button.connect("clicked", lambda w: self.file_ok_sel)
self.filesel.ok_button.connect("clicked", lambda w: self.filesel.destroy())
self.filesel.cancel_button.connect("clicked", lambda w: self.filesel.destroy())
self.filesel.set_filename("../images/guns/glock.gif")
self.filesel.show()
def file_ok_sel(self, w):
global filename
filename = self.filesel.get_filename()
# # # # # # # #
# 3.Functions #
# # # # # # # #
def i_wall():
i_wall = gtk.Image()
i_wall.set_from_file("../images/fields/wall.gif")
i_wall.show()
return i_wall
def i_leer():
i_leer = gtk.Image()
i_leer.set_from_file("../images/fields/0leer.gif")
i_leer.show()
return i_leer
def i_barricada():
i_barricada = gtk.Image()
i_barricada.set_from_file("../images/fields/barricada.gif")
i_barricada.show()
return i_barricada
def i_treasure():
i_treasure = gtk.Image()
i_treasure.set_from_file("../images/fields/treasure.gif")
i_treasure.show()
return i_treasure
def i_player():
i_player = gtk.Image()
i_player.set_from_file("../images/characters/player.gif")
i_player.show()
return i_player
def i_1one():
i_1one = gtk.Image()
i_1one.set_from_file("../images/characters/1one.gif")
i_1one.show()
return i_1one
def i_circle():
i_circle = gtk.Image()
i_circle.set_from_file("../images/kreis.gif")
i_circle.show()
return i_circle
def create_file(filename):
""" tests if file exists - if not it creates an empty dict in it.
:param filename: string - file path to create
"""
try:
with open(filename, "rb"):
return
except IOError:
print("ERROR: ", filename, " doesn't exist, is created instead.")
with open(filename, "wb") as file:
dct = {}
pickle.dump(dct, file)
def create_enemy():
""" creating enemy classes and saving them in resources/enemies """
print("Create an enemy.")
window = CreateEnemyWin()
newdict = window.main()
print("Saving enemy in resources/enemies...")
create_file("../resources/enemies")
with open("../resources/enemies", "rb") as file:
allenemies = pickle.load(file)
for i in newdict:
allenemies[i] = newdict[i]
with open("../resources/enemies", "wb") as file:
pickle.dump(allenemies, file)
print("Enemy saved.")
def create_gun():
""" creating gun classes and saving them in resources/guns """
print("Create a gun.")
window = CreateGunWin()
newdict = window.main()
print("Saving gun in resources/guns...")
create_file("../resources/guns")
with open("../resources/guns", "rb") as file:
allenemies = pickle.load(file)
for i in newdict:
allenemies[i] = newdict[i]
with open("../resources/guns", "wb") as file:
pickle.dump(allenemies, file)
print("Gun saved.")
def create_fielddata_entry(room):
""" Create a fielddata entry for a room
:param room: Room object
:return: room: Room object
"""
choice = 0
while choice == 0:
print("0 : Abort")
for entry in room.fielddata:
print(str(entry) + " : " + room.fielddata[entry])
try:
choice = int(raw_input("Which entry do you want to create? Pick a number which "
"is not given yet. delete it if you want to update an "
"existing: "))
except ValueError:
print("ERROR: Enter a number.")
if choice == 0:
return room
elif choice in room.fielddata:
print("ERROR: " + str(choice) + " is already in fielddata. Try again.")
choice = 0
else:
room.fielddata[choice] = raw_input("Enter the content of " + str(choice) + ": ")
return room
def erase_fielddata_entry(room):
"""
:param room: Room object
:return: room: Room object
"""
choice = 0
while choice == 0:
print("0 : Abort")
for entry in room.fielddata:
print(str(entry) + " : " + room.fielddata[entry])
try:
choice = int(raw_input("Which entry do you want to delete? "))
except ValueError:
print("ERROR: Enter a number.")
if choice == 0:
return room
elif choice in room.fielddata:
del room.fielddata[choice]
return room
else:
print("ERROR: " + str(choice) + " is not in fielddata. Try again.")
choice = 0
def choose_target_enemy(room):
for i in room.fielddata:
print i, room.fielddata[i]
choice = 0
while choice == 0:
try:
choice = int(raw_input("Which enemy is to be killed? "))
except ValueError:
print("ERROR: Enter a number.")
choice = 0
room.fielddata["target"] = choice
def create_room():
window = RoomEditor()
window.main()
choice = 0
while choice == 0:
print("(1) Create a fielddata entry")
print("(2) Erase a fielddata entry")
print("(3) Choose a target enemy")
print("(4) Finish room creation")
try:
choice = int(raw_input("What do you want to do? "))
except ValueError:
print("ERROR: Enter a number.")
if choice == 1:
create_fielddata_entry(window.room)
elif choice == 2:
erase_fielddata_entry(window.room)
elif choice == 3:
choose_target_enemy(window.room)
elif choice == 4:
print("Back to mission creation.")
return window.room
else:
print("ERROR: Enter a number between 1 and 5.")
choice = 0
def choose_room(rooms, string):
choice = "y"
while choice == "y":
for i in rooms:
print str(id(i)), i.description
try:
choice = raw_input(string)
except ValueError:
print("ERROR: Enter the ID of the room.")
for i in rooms:
try:
if id(i) == int(choice):
return i
except ValueError:
if i.description == choice:
return i
print("ERROR: ID is not in room list.")
choice = "y"
def create_mission():
""" mission creation func
rewardmoney # integer
rewarditems # list of Item-objects
rewardxp # integer
description # string
room # Room-object where to start
target_item # string (name of item) - default: None
target_enemy # integer (how many enemies have target attribute) - default: 0
target_coordinates # list (x,y,roomID) - default: None
"""
name = 0
while name == 0:
name = raw_input("What shall be the name of the mission? ")
if name in os.listdir("../missions"):
print("ERROR: Mission name already taken.")
name = 0
rooms = []
choice = "y"
while choice == "y":
print("Create a room.")
rooms.append(create_room())
try:
choice = raw_input("Do you want to create another room? (y/N) ")
except ValueError:
print("ERROR: Wrong input. Continuing mission creation.")
choice = "N"
room = choose_room(rooms, "Which room shall be the starting point? ")
print("Define success conditions:")
target_item = raw_input("Name of target item necessary to win the mission (leave "
"empty if not): ")
if target_item == "":
target_item = None
choice = raw_input("Do you want to define target coordinates? (y/N) ")
while choice == "y":
targetroom = choose_room(rooms, "Which room shall the target position be in? ")
field_choice_win = Choose_Field_Window(targetroom)
xy = field_choice_win.main()
target_coordinates = [xy[0], xy[1], targetroom]
choice = raw_input("Do you want to create another target position? (y/N) ")
else:
target_coordinates = None
target_enemy = 0
for r in rooms:
if "target" in r.fielddata:
for i in r.fields:
for j in i:
if r.fielddata["target"] == j:
target_enemy += 1
print(str(target_enemy) + " target enemies in mission.")
print("Enter additional data: ")
money = -1
while money == -1:
try:
money = int(raw_input("How much BTC shall be the reward? "))
except ValueError:
print("ERROR: Enter a number.")
money = -1
xp = -1
while xp == -1:
try:
xp = int(raw_input("How much XP shall be rewarded? "))
except ValueError:
print("ERROR: Enter a number.")
xp = -1
items = [] # Add reward items as soon as there is a modular item system.
print("Enter a mission description:")
description = raw_input()
mission = game.Mission(money, items, xp, description, room, rooms, target_item,
target_enemy, target_coordinates)
print("Mission created. Saving mission as missions/" + name + "...")
with open("../missions/" + name, mode="wb") as file:
pickle.dump(mission, file)
print("Mission saved.")
def main():
choice = 0
while choice == 0:
print("(1) Create a mission\n(2) Create a room (useless)\n(3) Create a gun")
print("(4) Create a sword\n(5) Create an enemy\n(6) Exit the editor")
try:
choice = int(raw_input("What do you want to do? "))
except ValueError:
print("ERROR: Enter a number.")
if choice == 1:
create_mission()
elif choice == 2:
create_room()
elif choice == 3:
create_gun()
elif choice == 4:
pass
# create_sword()
elif choice == 5:
create_enemy()
elif choice == 6:
print("Good Bye.")
exit()
else:
print("ERROR: Enter a number between 1 and 5.")
choice = 0
if __name__ == "__main__":
main()

218
code/enemies.py

@ -0,0 +1,218 @@
# coding=utf-8
# name, race, cons, strs, agis, mobs, ints, gun, sword, image, bitcoinloot (arguments for randint())
import items
from random import randint
def getenemyid():
""" give a character an unique ID.
in build_battlefield(), a foelist is created, in which the character
objects are created, whose constructor triggers this function, which
gives them an unique ID.
:return integer
"""
global enemyidcounter
enemyidcounter += 1
return enemyidcounter
# This global var increments every time an enemy gets an ID.
enemyidcounter = 0
class Enemy(object):
""" enemy superclass. this one could get some useful methods one day. """
def __init__(self, name, race, image, con, str, agi, mob, int, gun, sword,
loot, experience):
self.name = name # string
self.race = race # string
self.image = image # string: path to image
self.con = con # integer
self.str = str # integer
self.agi = agi # integer
self.mob = mob # integer
self.int = int # integer
allitems = items.AllItems()
if gun == "random":
self.gun = self.randitem(self.allitems.buyablegunsC)
else:
self.gun = allitems.buyablegunsC[gun]() # string: items.gun
if sword == "random":
self.sword = self.randitem(self.allitems.buyableswordsC)
else:
self.sword = allitems.buyableswordsC[sword] # string: items.sword
self.loot = loot # list of 2 arguments for randint()
self.experience = experience
# integer, how much experience player gets at killing asd
self.id = getenemyid()
self.max_hp = self.con * 8 + self.str * 5 + 10
self.hp = self.max_hp
self.ic = 1
def showinfo(self):
pass # open an infobox with info about the enemy on right-click
def walk_ap(self):
"""
returns, how many AP 1 step is costing
:return: integer
"""
walk_ap = 100 / self.mob
return walk_ap
def randitem(self, dict):
lst = []
for i in dict:
if i is not "random":
lst.append(dict[i])
number = randint(0, len(lst))
return lst[number]
"""
class Citizen(Enemy):
def __init__(self):
super(Citizen, self).__init__("Citizen", "human", "", 3, 3, 3, 3, 4,
"None", "None", [5, 15], 0)
class Boss(Enemy):
def __init__(self):
super(Boss, self).__init__("Boss", "human", "", 7, 6, 6, 7, 4,
"random", "random", [40, 70], 9)
class Police(Enemy):
def __init__(self):
super(Police, self).__init__("Police officer", "human", "", 4, 5, 5,
4, 4, "glock", "teli", [5, 10], 5)
class Security(Enemy):
def __init__(self):
super(Security, self).__init__("Private Security", "human", "", 5, 7,
5, 4, 4, "random", "teli", [1, 10], 6)
class Mercenary(Enemy):
def __init__(self):
super(Mercenary, self).__init__("Mercenary", "human", "", 6, 8, 8, 6,
4, "ak74", "knife", [5, 20], 7)
class Soldier(Enemy):
def __init__(self):
super(Soldier, self).__init__("Soldier", "human", "", 7, 8, 8, 7, 4,
"random", "knife", [10, 20], 8)
class Taskforce(Enemy):
def __init__(self):
super(Taskforce, self).__init__("Task Force", "human", "", 9, 10, 10,
9, 7, "random", "random", [10, 5], 10)
class Criminal(Enemy):
def __init__(self):
super(Criminal, self).__init__("Criminal", "human", "", 5, 6, 7, 7, 6,
"random", "random", [1, 15], 6)
class Terrorist(Enemy):
def __init__(self):
super(Terrorist, self).__init__("Terrorist", "human", "", 5, 7, 9, 8,
6, "random", "random", [1, 15], 7)
class Silver1(Enemy):
def __init__(self):
super(Silver1, self).__init__("Besorgt", "human", "", 4, 5, 5, 4, 2,
"random", "silversword",
[1, 10], 7)
class Silver2(Enemy):
def __init__(self):
super(Silver2, self).__init__("Fascist", "human", "", 8, 10, 8, 5, 2,
"random", "whip", [10, 20], 11)
class Angel1(Enemy):
def __init__(self):
super(Angel1, self).__init__("Angel", "angel", "", 5, 3, 8, 7, 6,
"random", "random", [10, 15], 8)
class Angel2(Enemy):
def __init__(self):
super(Angel2, self).__init__("High Angel", "angel", "", 6, 4, 10, 8,
7, "random", "random", [15, 25], 12)
class Vampire1(Enemy):
def __init__(self):
super(Vampire1, self).__init__("Vampire", "vampire", "", 7, 9, 5, 5,
6, "random", "random", [10, 15], 8)
class Vampire2(Enemy):
def __init__(self):
super(Vampire2, self).__init__("Dark Vampire", "vampire", "", 8, 11,
6, 6, 7, "random", "random", [15, 25],
12)
class Werewolf1(Enemy):
def __init__(self):
super(Werewolf1, self).__init__("Werewolf", "werewolf", "", 4, 5, 6,
5, 5, "random", "krallen", [10, 15], 8)
class Werewolf2(Enemy):
def __init__(self):
super(Werewolf2, self).__init__("Furious Werewolf ", "werewolf", "",
5, 8, 6, 6, 5, "random",
"silverkrallen", [15, 25], 12)
# You can create an enemy object by calling: enemies.all_enemies[name]()
all_enemies = {
"Citizen": Citizen, "Boss": Boss, "Police Officer": Police,
"Private Security": Security, "Mercenary": Mercenary, "Soldier": Soldier,
"Task Force": Taskforce, "Criminal": Criminal, "Terrorist": Terrorist,
"Besorgt": Silver1, "Fascist": Silver2, "Angel": Angel1,
"High Angel": Angel2, "Vampire": Vampire1, "Dark Vampire": Vampire2,
"Werewolf": Werewolf1, "Furious Werewolf": Werewolf2
}
civilian = ["Citizen", "human", "", 0, 0, 0, 0, 0, "None", "None", [5, 15], 0]
boss = ["Boss", "human", 7, 6, 6, 7, 0, "random", "random", [40, 70], 9]
police = ["Police Officer", "human", "", 0, 0, 0, 0, 0, "glock", "teli", [5, 10], 5]
security = ["Private Security", "human", "", 1, 2, 0, 0, 0, "random", "teli", [1, 10], 6]
mercenary = ["Mercenary", "human", "", 2, 3, 2, 2, 1, "ak74", "knife", [5, 20], 7]
soldier = ["Soldier", "human", "", 3, 3, 3, 3, 2, "random", "knife", [10, 20], 8]
taskforce = ["Task force", "human", "", 5, 5, 5, 5, 3, "random", "random", [10, 50], 10]
criminal = ["Criminial", "human", "", 1, 1, 2, 3, 2, "random", "random", [1, 15], 6]
terrorist = ["Terrorist", "human", "", 1, 2, 4, 4, 2, "random", "random", [1, 15], 7]
silver1 = ["Besorgt", "human", "", 0, 0, 0, 0, 0, "random", "silversword", [1, 10], 7]
silver2 = ["Fascist", "human", "", 4, 5, 3, 1, 3, "random", "whip", [10, 20], 11]
angel1 = ["Angel", "angel", "", 1, 0, 1, 0, 1, "random", "random", [10, 15], 8]
angel2 = ["Angel", "angel", "", 2, 1, 3, 1, 2, "random", "random", [15, 25], 12]
vampire1 = ["Vampire", "vampire", "", 1, 1, 0, 0, 1, "random", "random", [10, 15], 8]
vampire2 = ["Vampire", "vampire", "", 2, 3, 1, 1, 2, "random", "random", [15, 25], 12]
werewolf1 = ["Werewolf", "werewolf", "", 0, 0, 1, 1, 1, "random", "krallen", [10, 15], 8]
werewolf2 = ["Werewolf", "werewolf", "", 1, 3, 1, 2, 1, "random", "silverkrallen", [15, 25], 12]
all_enemies = {
"Citizen": civilian, "Boss": boss, "Police Officer": police,
"Private Security": security, "Mercenary": mercenary, "Soldier": soldier,
"Task Force": taskforce, "Criminal": criminal, "Terrorist": terrorist,
"Besorgt": silver1, "Fascist": silver2, "Angel": angel1,
"High Angel": angel2, "Vampire": vampire1, "Dark Vampire": vampire2,
"Werewolf": werewolf1, "Furious Werewolf": werewolf2
} """

1298
code/game.py
File diff suppressed because it is too large
View File

304
code/items.py

@ -0,0 +1,304 @@
#! /usr/bin/env python
# coding=utf-8
# from random import randint
# Main Classes
class Item(object):
""" major item class """
def __init__(self, name, price, image):
self.name = name # string: item name
self.price = price # integer: price in BTC
self.image = image # string containing path to image
class Gun(Item):
""" gun subclass """
def __init__(self, name, price, image, damage, grange, ap):
super(Gun, self).__init__(name, price, image)
self.damage = damage # Integer
self.grange = grange # Integer
self.ap = ap # Integer, AP needed to fire the gun
self.type = "gun"
class Sword(Item):
""" sword subclass """
def __init__(self, name, price, image, ap, critical, stun, damage,
silverdamage):
super(Sword, self).__init__(name, price, image)
self.damage = damage # integer: damage dealt
self.ap = ap # integer: ap needed to attack
self.critical = critical # float: chance to do critical damage
self.stun = stun # float: change to stun enemy
self.silverdamage = silverdamage # boolean: does extra damage to SUPs
self.type = "sword"
"""
# Swords
# name
# price
# path to image (empty string until artwork is done)
# AP
# Critical ( Damage*2 )
# Stun
# Damage
# Silverdamage ( Damage*2 )
class Nosword(Sword):
def __init__(self):
super(Nosword, self).__init__("Fist", 0, "", 50, 0.0, 0.3, 0, False)
class Baton(Sword):
def __init__(self):
super(Baton, self).__init__("Baton", 20, "", 75, 0.0, 0.3, 20, False)
class Knife(Sword):
def __init__(self):
super(Knife, self).__init__("Knife", 20, "", 60, 0.2, 0.0, 30, False)
class Shortsword(Sword):
def __init__(self):
super(Shortsword, self).__init__("Short sword", 40, "", 90, 0.3, 0.0,
50, False)
class Longsword(Sword):
def __init__(self):
super(Longsword, self).__init__("Long sword", 70, "", 120, 0.4, 0.1,
70, False)
class NunChaku(Sword):
def __init__(self):
super(NunChaku, self).__init__("Nun-Chakus", 70, "", 80, 0.1, 0.7, 50,
False)
class Mace(Sword):
def __init__(self):
super(Mace, self).__init__("Mace", 70, "", 100, 0.1, 0.5, 70, False)
class Claymore(Sword):
def __init__(self):
super(Claymore, self).__init__("Claymore", 120, "", 150, 0.3, 0.2,
120, False)
class Katana(Sword):
def __init__(self):
super(Katana, self).__init__("Katana", 100, "", 110, 0.6, 0.1, 75,
False)
class Silversword(Sword):
def __init__(self):
super(Silversword, self).__init__("Silver sword", 90, "", 120, 0.3,
0.2, 50, True)
class Silverdagger(Sword):
def __init__(self):
super(Silverdagger, self).__init__("Silver dagger", 40, "", 60, 0.2,
0.0, 30, True)
class Whip(Sword):
def __init__(self):
super(Whip, self).__init__("Silver whip", 60, "", 150, 0.7, 0.8, 30,
True)
class Claws(Sword):
def __init__(self):
super(Claws, self).__init__("Claws", 50, "", 50, 0.3, 0.6, 30, False)
class Silverclaws(Sword):
def __init__(self):
super(Silverclaws, self).__init__("Silver Claws", 150, "", 50, 0.4,
0.7, 30, True)
# Guns
# Name
# Cost
# Path to image (empty until artworks are done)
# Damage
# g(un)Range
# AP needed to fire gun
# max. 2 Upgrades
class Nogun(Gun):
def __init__(self):
super(Nogun, self).__init__("No gun", 0, "", 0, 0, 0)
class Glock(Gun):
def __init__(self):
super(Glock, self).__init__("Glock", 30, "", 10, 8, 100)
class Uzi(Gun):
def __init__(self):
super(Uzi, self).__init__("uzi", 50, "", 10, 6, 50)
class Ak74(Gun):
def __init__(self):
super(Ak74, self).