initial commit - 0ldsk00l
This commit is contained in:
28
README.txt
Normal file
28
README.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/////////////////////////
|
||||||
|
\\\\ cursedmate v0.1b\\\\
|
||||||
|
\\\\\\\\\\\\\\\\\\\\\\\\\\
|
||||||
|
|
||||||
|
main()
|
||||||
|
======
|
||||||
|
|
||||||
|
building in 2010 oldshool games - heya!
|
||||||
|
during reading the ncurses lib for python
|
||||||
|
this little piece of software was put
|
||||||
|
together. sweeeeet.
|
||||||
|
|
||||||
|
facts()
|
||||||
|
=======
|
||||||
|
|
||||||
|
* 20 levels
|
||||||
|
* 35 exploits spends a life
|
||||||
|
* monsters alias fedz, whitehats, blackhats(whatever ur enemy is) try to eat u
|
||||||
|
* run for the exploits to make it to the next level and escalating privs
|
||||||
|
* in the end i spent more time on it as i planned, but i think it was worth it
|
||||||
|
|
||||||
|
final()
|
||||||
|
=======
|
||||||
|
|
||||||
|
shouts to my friends, you know who u are!
|
||||||
|
|
||||||
|
have fun,
|
||||||
|
dash
|
||||||
161
cmate.py
Executable file
161
cmate.py
Executable file
@@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#this is not even an exploit!!!1111
|
||||||
|
|
||||||
|
# Copyright (C) 2010 dash@uberwall.org
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# 3. All advertising materials mentioning features or use of this software
|
||||||
|
# must display the following acknowledgement:
|
||||||
|
# This product includes software developed by dash.
|
||||||
|
# 4. The name dash may not be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
|
||||||
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
import cmatescenes
|
||||||
|
import cmatelib
|
||||||
|
import random
|
||||||
|
import curses
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
def play_level(win1,win2,cm,mspeed):
|
||||||
|
|
||||||
|
try:
|
||||||
|
cm.update_lifebar(win1)
|
||||||
|
win1.move(cm.sizex/2,cm.sizey/2)
|
||||||
|
curses.curs_set(1)
|
||||||
|
win1.nodelay(1)
|
||||||
|
o=0
|
||||||
|
while 1:
|
||||||
|
a = win1.getch()
|
||||||
|
if a == 65:
|
||||||
|
cm.move_player(a,win1)
|
||||||
|
elif a == 66:
|
||||||
|
cm.move_player(a,win1)
|
||||||
|
elif a == 68:
|
||||||
|
cm.move_player(a,win1)
|
||||||
|
elif a == 67:
|
||||||
|
cm.move_player(a,win1)
|
||||||
|
elif a == 112:
|
||||||
|
cmatescenes.pause_game(win2,cm)
|
||||||
|
win1.redrawwin()
|
||||||
|
|
||||||
|
cm.check_position(win1)
|
||||||
|
|
||||||
|
if (o%mspeed == 0):
|
||||||
|
cm.move_monster(win1)
|
||||||
|
|
||||||
|
#watch out for ur lifes
|
||||||
|
ret = cm.check_collision(win1)
|
||||||
|
if ret == 1:
|
||||||
|
cmatescenes.lost_a_live(win2,cm)
|
||||||
|
win1.move(cm.sizex-2,cm.sizey-2)
|
||||||
|
time.sleep(2)
|
||||||
|
cm.update_lifebar(win1)
|
||||||
|
win1.redrawwin()
|
||||||
|
if cm.lives < 0:
|
||||||
|
cmatescenes.ur_dead(win2,cm)
|
||||||
|
return -1
|
||||||
|
|
||||||
|
#check if a zero day was eaten
|
||||||
|
cm.check_object(win1)
|
||||||
|
|
||||||
|
if cm.gcount + cm.eaten >= cm.gold:
|
||||||
|
cmatescenes.congrats(win2,cm)
|
||||||
|
return 0
|
||||||
|
if cm.gold == cm.gcount:
|
||||||
|
cmatescenes.congrats(win2,cm)
|
||||||
|
return 0
|
||||||
|
o+=1
|
||||||
|
|
||||||
|
if cm.elive == 35:
|
||||||
|
cm.lives+=1
|
||||||
|
cm.elive = 0
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
if cmatescenes.really_quit(win2,cm) != -1:
|
||||||
|
cm.close_stdscr()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def create_level(win1,win2,cm,ming,maxg,minm,maxm):
|
||||||
|
rc = random.randint(0,10)
|
||||||
|
cm.config_window(win1,1)
|
||||||
|
cm.generate_map(cm.sizex-1,cm.sizey-1)
|
||||||
|
cm.generate_item(500,1000,35)
|
||||||
|
cm.generate_gold(int(ming),int(maxg))
|
||||||
|
cm.generate_monster(int(minm),int(maxm))
|
||||||
|
cm.throw_items(win1,rc)
|
||||||
|
cmatescenes.level_info(win2,cm)
|
||||||
|
cm.throw_items(win1,rc)
|
||||||
|
cm.update_lifebar(win1)
|
||||||
|
win1.move(cm.sizex/2,cm.sizey/2)
|
||||||
|
win1.refresh()
|
||||||
|
|
||||||
|
cm = cmatelib.cmate()
|
||||||
|
cm.create_stdscr()
|
||||||
|
cm.create_colors()
|
||||||
|
|
||||||
|
cm.sizex=24
|
||||||
|
cm.sizey=80
|
||||||
|
|
||||||
|
cmatescenes.pre_intro(cm,2)
|
||||||
|
cmatescenes.intro(cm)
|
||||||
|
win1 = cm.create_window(cm.sizex,cm.sizey,0,0)
|
||||||
|
win2 = cm.create_window(8,50,5,16)
|
||||||
|
win3 = cm.create_window(16,50,5,16)
|
||||||
|
cmatescenes.start_of_game(win3,cm)
|
||||||
|
|
||||||
|
#open level file
|
||||||
|
l = open('levelfile.txt','r')
|
||||||
|
for lvl in l.readlines():
|
||||||
|
if lvl[0]!='#' and lvl[0]!='\n':
|
||||||
|
cm.gcount=0
|
||||||
|
cm.eaten=0
|
||||||
|
cm.gomap=[]
|
||||||
|
cm.mmap=[]
|
||||||
|
items = lvl.split(',')
|
||||||
|
level=items[0]
|
||||||
|
ming=items[1]
|
||||||
|
maxg=items[2]
|
||||||
|
minm=items[3]
|
||||||
|
maxm=items[4]
|
||||||
|
mspeed=items[5]
|
||||||
|
cm.lvl=level
|
||||||
|
create_level(win1,win2,cm,ming,maxg,minm,maxm)
|
||||||
|
|
||||||
|
while 1:
|
||||||
|
ret = play_level(win1,win2,cm,int(mspeed))
|
||||||
|
if ret ==0:
|
||||||
|
break
|
||||||
|
elif ret ==-1:
|
||||||
|
endgame=-1
|
||||||
|
cm.close_stdscr()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
cmatescenes.pre_intro(cm,1)
|
||||||
|
|
||||||
|
cmatescenes.end_of_game(win2,cm)
|
||||||
|
|
||||||
|
#the end
|
||||||
|
cm.close_stdscr()
|
||||||
432
cmatelib.py
Normal file
432
cmatelib.py
Normal file
@@ -0,0 +1,432 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# Copyright (C) 2010 dash@uberwall.org
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# 3. All advertising materials mentioning features or use of this software
|
||||||
|
# must display the following acknowledgement:
|
||||||
|
# This product includes software developed by dash.
|
||||||
|
# 4. The name dash may not be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
|
||||||
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
import random
|
||||||
|
import curses
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
class cmate(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.name="the hunt for 0days"
|
||||||
|
self.lvl=0
|
||||||
|
self.gold=0
|
||||||
|
self.gcount=0
|
||||||
|
self.collected=0
|
||||||
|
self.eaten=0
|
||||||
|
self.ms=0
|
||||||
|
self.elive=0
|
||||||
|
self.lives=3
|
||||||
|
self.time=60
|
||||||
|
self.gmap=[]
|
||||||
|
self.mmap=[]
|
||||||
|
self.gomap=[]
|
||||||
|
self.win1=0
|
||||||
|
self.win2=0
|
||||||
|
self.sizex=25
|
||||||
|
self.sizey=80
|
||||||
|
self.winlist=[]
|
||||||
|
self.stdscr=0
|
||||||
|
self.msspeed=100
|
||||||
|
|
||||||
|
def close_stdscr(self):
|
||||||
|
""" at the end - we reset everything """
|
||||||
|
curses.nocbreak()
|
||||||
|
curses.echo()
|
||||||
|
self.stdscr.keypad(0)
|
||||||
|
curses.endwin()
|
||||||
|
|
||||||
|
def create_stdscr(self):
|
||||||
|
""" function for the stdscr """
|
||||||
|
self.stdscr = curses.initscr()
|
||||||
|
self.stdscr.border()
|
||||||
|
self.stdscr.keypad(1)
|
||||||
|
|
||||||
|
curses.cbreak()
|
||||||
|
curses.noecho()
|
||||||
|
curses.start_color()
|
||||||
|
curses.curs_set(1)
|
||||||
|
|
||||||
|
def create_colors(self):
|
||||||
|
curses.init_pair(1,curses.COLOR_GREEN,curses.COLOR_BLACK)
|
||||||
|
curses.init_pair(2,curses.COLOR_YELLOW,curses.COLOR_BLACK)
|
||||||
|
curses.init_pair(3,curses.COLOR_RED,curses.COLOR_BLACK)
|
||||||
|
curses.init_pair(4,curses.COLOR_WHITE,curses.COLOR_BLACK)
|
||||||
|
curses.init_pair(5,curses.COLOR_WHITE,curses.COLOR_RED)
|
||||||
|
curses.init_pair(6,curses.COLOR_YELLOW,curses.COLOR_BLUE)
|
||||||
|
curses.init_pair(7,curses.COLOR_WHITE,curses.COLOR_BLUE)
|
||||||
|
curses.init_pair(8,curses.COLOR_WHITE,curses.COLOR_WHITE)
|
||||||
|
curses.init_pair(9,curses.COLOR_YELLOW,curses.COLOR_YELLOW)
|
||||||
|
curses.init_pair(10,curses.COLOR_BLACK,curses.COLOR_BLACK)
|
||||||
|
|
||||||
|
def check_windows(self):
|
||||||
|
""" how many windows are in the list """
|
||||||
|
wlen = len(self.winlist)
|
||||||
|
return wlen
|
||||||
|
|
||||||
|
def create_window(self,sizex,sizey,posx,posy):
|
||||||
|
""" function for creating a new window """
|
||||||
|
win = curses.newwin(sizex,sizey,posx,posy)
|
||||||
|
self.winlist.append(win)
|
||||||
|
return win
|
||||||
|
|
||||||
|
def compute_strpos(self,win,pos,string):
|
||||||
|
""" find relative positions for texts in the middle of the window"""
|
||||||
|
sizex,sizey = win.getmaxyx()
|
||||||
|
if pos == 1:
|
||||||
|
l = len(string)
|
||||||
|
spos = sizey - l
|
||||||
|
rpos = spos /2
|
||||||
|
|
||||||
|
return rpos
|
||||||
|
|
||||||
|
def write_window(self,win,posx,posy,text,attr):
|
||||||
|
""" wrapper function for writing strings to a window """
|
||||||
|
if posx!=-1 and posy!=-1 and attr !=-1:
|
||||||
|
win.addstr(posx,posy,text,attr)
|
||||||
|
elif posx!=-1 and posy!=-1 and attr == -1:
|
||||||
|
win.addstr(posx,posy,text)
|
||||||
|
elif posx==-1 and posy==-1 and attr == -1:
|
||||||
|
win.addstr(text)
|
||||||
|
elif posx==-1 and posy==-1 and attr !=-1:
|
||||||
|
win.addstr(text,attr)
|
||||||
|
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
def config_window(self,win,func):
|
||||||
|
if func==1:
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
elif func == 2:
|
||||||
|
win.erase()
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
def generate_map(self,x,y):
|
||||||
|
fill = 35 # 35 is the fill element '#'
|
||||||
|
gmap = []
|
||||||
|
fields = x*y
|
||||||
|
i = 0
|
||||||
|
for cx in range(0,x):
|
||||||
|
for cy in range(0,y):
|
||||||
|
gmap.append([cx,cy,32])
|
||||||
|
i+=1
|
||||||
|
i+=1
|
||||||
|
self.gmap = gmap
|
||||||
|
|
||||||
|
def generate_monster(self,f,t):
|
||||||
|
|
||||||
|
#gmap
|
||||||
|
gmap = self.gmap
|
||||||
|
#monsters
|
||||||
|
ms = [f,t]
|
||||||
|
ms = random.randint(ms[0],ms[1])
|
||||||
|
l = len(gmap)-1
|
||||||
|
mmap=[]
|
||||||
|
|
||||||
|
for g in range(0,ms):
|
||||||
|
while 1:
|
||||||
|
p = random.randint(0,l)
|
||||||
|
if (gmap[p][0] != 0 and gmap[p][1] != 0) and (gmap[p][0] != 23 and gmap[p][1] != 79):
|
||||||
|
gmap[p][2] = 164
|
||||||
|
mmap.append(gmap[p])
|
||||||
|
break
|
||||||
|
|
||||||
|
self.gmap = gmap
|
||||||
|
self.mmap = mmap
|
||||||
|
self.ms = ms
|
||||||
|
|
||||||
|
def generate_gold(self,f,t):
|
||||||
|
|
||||||
|
gmap = self.gmap
|
||||||
|
|
||||||
|
#gold aka 0days
|
||||||
|
gold = [f,t]
|
||||||
|
gold = random.randint(gold[0],gold[1])
|
||||||
|
l = len(gmap)-1
|
||||||
|
|
||||||
|
for g in range(0,gold):
|
||||||
|
while 1:
|
||||||
|
p = random.randint(0,l)
|
||||||
|
if (gmap[p][0] != 0 and gmap[p][1] != 0) and (gmap[p][0] != 23 and gmap[p][1] != 79):
|
||||||
|
gmap[p][2] = 163
|
||||||
|
self.gomap.append(gmap[p])
|
||||||
|
break
|
||||||
|
|
||||||
|
self.gold = gold
|
||||||
|
self.gmap = gmap
|
||||||
|
|
||||||
|
def generate_item(self,f,t,item):
|
||||||
|
|
||||||
|
gmap = self.gmap
|
||||||
|
#chill number 35
|
||||||
|
f = [f,t]
|
||||||
|
f = random.randint(f[0],f[1])
|
||||||
|
l = len(gmap)-1
|
||||||
|
for g in range(0,f):
|
||||||
|
while 1:
|
||||||
|
p = random.randint(0,l)
|
||||||
|
if (gmap[p][0] != 0 and gmap[p][1] != 0) and (gmap[p][0] != 23 and gmap[p][1] != 79) and gmap[p][2] != 163:
|
||||||
|
gmap[p][2] = item
|
||||||
|
break
|
||||||
|
|
||||||
|
self.gmap = gmap
|
||||||
|
|
||||||
|
def throw_items(self,win,rc):
|
||||||
|
""" populate the map with the window with pre-generated items in gmap """
|
||||||
|
gmap = self.gmap
|
||||||
|
|
||||||
|
#general map
|
||||||
|
for val in gmap:
|
||||||
|
if (val[0] != 0 and val[1] != 0) and (val[0] != 23 and val[1] != 79):
|
||||||
|
if val[2] == 163:
|
||||||
|
win.addstr(val[0],val[1],chr(val[2]),curses.A_REVERSE)
|
||||||
|
win.refresh()
|
||||||
|
elif val[2] == 164:
|
||||||
|
win.addstr(val[0],val[1],chr(val[2]),curses.color_pair(5))
|
||||||
|
win.refresh()
|
||||||
|
else:
|
||||||
|
win.addstr(val[0],val[1],chr(val[2]),curses.color_pair(rc))
|
||||||
|
win.refresh()
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
|
||||||
|
self.gmap = gmap
|
||||||
|
|
||||||
|
def update_lifebar(self,win):
|
||||||
|
""" show the player whats going on """
|
||||||
|
|
||||||
|
#save my coordinates
|
||||||
|
me = win.getyx()
|
||||||
|
|
||||||
|
#which level
|
||||||
|
collect = "lvl:%s" % (self.lvl)
|
||||||
|
win.addstr(0,3,collect)
|
||||||
|
|
||||||
|
#how much zerodays to grep
|
||||||
|
gold = "%s / %s" % (self.gcount,self.gold)
|
||||||
|
win.addstr(0,12,gold)
|
||||||
|
|
||||||
|
#zeroday collection
|
||||||
|
collect = "xploitz: %s" % (self.collected)
|
||||||
|
win.addstr(0,20,collect)
|
||||||
|
|
||||||
|
#lives
|
||||||
|
lives = "live: %d" % (self.lives)
|
||||||
|
win.addstr(0,35,lives)
|
||||||
|
|
||||||
|
#knights name
|
||||||
|
name = "%s" % (self.name)
|
||||||
|
win.addstr(0,50,name)
|
||||||
|
|
||||||
|
#time
|
||||||
|
#time = "%s" % (self.time)
|
||||||
|
#win.addstr(0,70,time)
|
||||||
|
|
||||||
|
|
||||||
|
#how many fedz and whittezzzz
|
||||||
|
fedz = "%s fedz" % (str(self.ms))
|
||||||
|
win.addstr(23,3, fedz)
|
||||||
|
|
||||||
|
#published by wh and eaten by fedz
|
||||||
|
ate = "[%s]" % (str(self.eaten))
|
||||||
|
win.addstr(23,20, ate)
|
||||||
|
|
||||||
|
win.move(me[0],me[1])
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
def check_object(self,win):
|
||||||
|
""" check if a monster ate our zeroday """
|
||||||
|
# f = open('logme.txt','a')
|
||||||
|
mmap = self.mmap
|
||||||
|
gomap = self.gomap
|
||||||
|
for gold in gomap:
|
||||||
|
for monster in mmap:
|
||||||
|
if gold[0] == monster[0] and gold[1] == monster[1]:
|
||||||
|
self.eaten=int(self.eaten) + 1
|
||||||
|
gomap.remove(gold)
|
||||||
|
#g = "%s\n" % (gold)
|
||||||
|
#f.write(g)
|
||||||
|
#m = "%s\n" % (monster)
|
||||||
|
#f.write(m)
|
||||||
|
self.update_lifebar(win)
|
||||||
|
#f.close()
|
||||||
|
self.gomap = gomap
|
||||||
|
|
||||||
|
def check_position(self,win):
|
||||||
|
""" checks position for gold, this function should be optimized as
|
||||||
|
by now the whole gmap is searched, which could be done simpler """
|
||||||
|
|
||||||
|
gmap = self.gmap
|
||||||
|
i=0
|
||||||
|
me = win.getyx()
|
||||||
|
for val in gmap:
|
||||||
|
if me[0] == val[0] and me[1] == val[1] and val[2] == 163:
|
||||||
|
|
||||||
|
self.gcount = int(self.gcount) + 1
|
||||||
|
self.elive = int(self.elive) + 1
|
||||||
|
self.collected = int(self.collected) + 1
|
||||||
|
self.update_lifebar(win)
|
||||||
|
|
||||||
|
#changing the field - clearing space
|
||||||
|
win.addch(me[0],me[1]," ")
|
||||||
|
|
||||||
|
#clearing space in table
|
||||||
|
gmap[i][2]=32
|
||||||
|
|
||||||
|
#ok i am back at the same old place
|
||||||
|
win.move(me[0],me[1])
|
||||||
|
win.refresh()
|
||||||
|
self.gmap = gmap
|
||||||
|
i+=1
|
||||||
|
|
||||||
|
def check_collision(self,win):
|
||||||
|
""" lets check if a monster is byting our ass """
|
||||||
|
|
||||||
|
me = win.getyx()
|
||||||
|
mmap = self.mmap
|
||||||
|
|
||||||
|
for val in mmap:
|
||||||
|
if val[0] == me[0] and val[1] == me[1]:
|
||||||
|
self.lives = self.lives - 1
|
||||||
|
return 1
|
||||||
|
|
||||||
|
return -1
|
||||||
|
|
||||||
|
def move_monster(self,win):
|
||||||
|
gmap = self.gmap
|
||||||
|
mmap = self.mmap
|
||||||
|
i=0
|
||||||
|
me = win.getyx()
|
||||||
|
for val in mmap:
|
||||||
|
|
||||||
|
m = random.randint(1,4)
|
||||||
|
|
||||||
|
#check what direction the random gen spitted
|
||||||
|
#check if monster has reached the cage
|
||||||
|
|
||||||
|
if m == 1:
|
||||||
|
if val[0]!=1:
|
||||||
|
win.addstr(val[0],val[1]," ")
|
||||||
|
x = val[0]
|
||||||
|
x = x - 1
|
||||||
|
mmap[i][0] = x
|
||||||
|
win.addstr(x,val[1],"O",curses.color_pair(5))
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
elif m == 2:
|
||||||
|
if val[0]!=self.sizex-2:
|
||||||
|
win.addstr(val[0],val[1]," ")
|
||||||
|
x = val[0]
|
||||||
|
x = x + 1
|
||||||
|
mmap[i][0] = x
|
||||||
|
win.addstr(x,val[1],"O",curses.color_pair(5))
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
elif m == 3:
|
||||||
|
if val[1]!=1:
|
||||||
|
win.addstr(val[0],val[1]," ")
|
||||||
|
y = val[1]
|
||||||
|
y = y - 1
|
||||||
|
mmap[i][1] = y
|
||||||
|
win.addstr(val[0],y,"O",curses.color_pair(5))
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
elif m == 4:
|
||||||
|
if val[1]!=self.sizey-2:
|
||||||
|
win.addstr(val[0],val[1]," ")
|
||||||
|
y = val[1]
|
||||||
|
y = y + 1
|
||||||
|
mmap[i][1] = y
|
||||||
|
win.addstr(val[0],y,"O",curses.color_pair(5))
|
||||||
|
win.refresh()
|
||||||
|
#former monster field is empty now
|
||||||
|
i+=1
|
||||||
|
|
||||||
|
win.move(me[0],me[1])
|
||||||
|
win.refresh()
|
||||||
|
self.mmap = mmap
|
||||||
|
|
||||||
|
def move_cursor(self,win, x,y):
|
||||||
|
""" for other useful and great animations """
|
||||||
|
win.move(x,y)
|
||||||
|
|
||||||
|
def delete_item(self, win, item, x,y):
|
||||||
|
""" for deleting the littel things at the position xy """
|
||||||
|
win.addch(x,y,item)
|
||||||
|
|
||||||
|
def move_item(self, win, item, x,y,color):
|
||||||
|
""" for moving "sprites" :) """
|
||||||
|
win.move(x,y)
|
||||||
|
self.write_window(win,x,y,item,color)
|
||||||
|
# win.refresh()
|
||||||
|
|
||||||
|
def move_player(self,action,win):
|
||||||
|
|
||||||
|
a = action
|
||||||
|
xy = win.getyx()
|
||||||
|
x=xy[0]
|
||||||
|
y=xy[1]
|
||||||
|
|
||||||
|
win.addch(x,y," ")
|
||||||
|
if a == 65:
|
||||||
|
if x!=1:
|
||||||
|
win.move(x-1,y)
|
||||||
|
win.refresh()
|
||||||
|
else:
|
||||||
|
win.move(x,y)
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
elif a == 66:
|
||||||
|
if x!=self.sizex-2:
|
||||||
|
win.move(x+1,y)
|
||||||
|
win.refresh()
|
||||||
|
else:
|
||||||
|
win.move(x,y)
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
elif a == 68:
|
||||||
|
if y!=1:
|
||||||
|
win.move(x,y-1)
|
||||||
|
win.refresh()
|
||||||
|
else:
|
||||||
|
win.move(x,y)
|
||||||
|
win.refresh()
|
||||||
|
|
||||||
|
elif a == 67:
|
||||||
|
if y!=self.sizey-2:
|
||||||
|
win.move(x,y+1)
|
||||||
|
win.refresh()
|
||||||
|
else:
|
||||||
|
win.move(x,y)
|
||||||
|
win.refresh()
|
||||||
BIN
cmatelib.pyc
Normal file
BIN
cmatelib.pyc
Normal file
Binary file not shown.
339
cmatescenes.py
Normal file
339
cmatescenes.py
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
# Copyright (C) 2010 dash@uberwall.org
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# 3. All advertising materials mentioning features or use of this software
|
||||||
|
# must display the following acknowledgement:
|
||||||
|
# This product includes software developed by dash.
|
||||||
|
# 4. The name dash may not be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
|
||||||
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
|
||||||
|
import cmatelib
|
||||||
|
import random
|
||||||
|
import curses
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
def pre_intro(cm,func):
|
||||||
|
""" what can i say, the coordinates are fucked up """
|
||||||
|
win20 = cm.create_window(cm.sizex,cm.sizey,0,0)
|
||||||
|
curses.curs_set(0)
|
||||||
|
x=0
|
||||||
|
y=13
|
||||||
|
y1=11
|
||||||
|
char="|"
|
||||||
|
while 1:
|
||||||
|
win20.hline(y,x,char,cm.sizey)
|
||||||
|
win20.hline(y1,x,char,cm.sizey)
|
||||||
|
y+=1
|
||||||
|
y1-=1
|
||||||
|
win20.refresh()
|
||||||
|
time.sleep(0.1)
|
||||||
|
if y == cm.sizex:
|
||||||
|
break
|
||||||
|
|
||||||
|
if func==1:
|
||||||
|
y=12
|
||||||
|
x=0
|
||||||
|
curses.curs_set(1)
|
||||||
|
while 1:
|
||||||
|
cm.move_cursor(win20,y,x)
|
||||||
|
win20.refresh()
|
||||||
|
time.sleep(0.1)
|
||||||
|
x+=1
|
||||||
|
if x == 80:
|
||||||
|
break
|
||||||
|
|
||||||
|
if func==2:
|
||||||
|
y=12
|
||||||
|
x=79
|
||||||
|
curses.curs_set(1)
|
||||||
|
while 1:
|
||||||
|
cm.move_cursor(win20,y,x)
|
||||||
|
win20.refresh()
|
||||||
|
time.sleep(0.1)
|
||||||
|
x-=1
|
||||||
|
if x == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
def intro(cm):
|
||||||
|
win5 = cm.create_window(cm.sizex,cm.sizey,0,0)
|
||||||
|
cm.config_window(win5,1)
|
||||||
|
welc = ".oOo.oOO w3lcome to cursedmate OOo.oOo."
|
||||||
|
rpos = cm.compute_strpos(win5,1,welc)
|
||||||
|
cm.write_window(win5,5,rpos,welc,curses.color_pair(2))
|
||||||
|
i = 0
|
||||||
|
y = 78
|
||||||
|
x = 16
|
||||||
|
y1 = 78
|
||||||
|
x1 = 16
|
||||||
|
while 1:
|
||||||
|
if y == 0:
|
||||||
|
curses.curs_set(0)
|
||||||
|
|
||||||
|
if y >= 0:
|
||||||
|
cm.move_cursor(win5,x,y)
|
||||||
|
|
||||||
|
if y == 60:
|
||||||
|
cm.move_item(win5,"O",x1,y1,curses.color_pair(5))
|
||||||
|
cm.config_window(win5,1)
|
||||||
|
curses.curs_set(0)
|
||||||
|
shitno0days = "oh shit!!111 it is a fed!!!"
|
||||||
|
rpos = cm.compute_strpos(win5,1,shitno0days)
|
||||||
|
cm.write_window(win5,(cm.sizex/4)+2,rpos,shitno0days,curses.color_pair(1))
|
||||||
|
time.sleep(2)
|
||||||
|
curses.curs_set(1)
|
||||||
|
elif y < 60:
|
||||||
|
if y1 == 0:
|
||||||
|
cm.delete_item(win5," ",x1,y1+1)
|
||||||
|
win5.refresh()
|
||||||
|
break
|
||||||
|
cm.delete_item(win5," ",x1,y1+1)
|
||||||
|
cm.move_item(win5,"O",x1,y1,curses.color_pair(5))
|
||||||
|
cm.config_window(win5,1)
|
||||||
|
y1 = y1 -1
|
||||||
|
|
||||||
|
if y >= 0:
|
||||||
|
cm.move_cursor(win5,x,y)
|
||||||
|
|
||||||
|
if y != 0 and y >= 50:
|
||||||
|
y = y -1
|
||||||
|
|
||||||
|
elif y > 2 and y <= 50:
|
||||||
|
y = y - 2
|
||||||
|
|
||||||
|
elif y <= 2 and y <=50:
|
||||||
|
y = y - 1
|
||||||
|
|
||||||
|
win5.refresh()
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
win5.nodelay(1)
|
||||||
|
win5.move(cm.sizex/2,rpos)
|
||||||
|
win5.box()
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
o = 100
|
||||||
|
win5.nodelay(1)
|
||||||
|
while 1:
|
||||||
|
a = win5.getch()
|
||||||
|
if i%o == 0:
|
||||||
|
space = "press <SPACE> to contiue"
|
||||||
|
rpos = cm.compute_strpos(win5,1,space)
|
||||||
|
cm.write_window(win5,cm.sizex/2,rpos,space,curses.color_pair(5))
|
||||||
|
win5.refresh()
|
||||||
|
time.sleep(3)
|
||||||
|
win5.move(cm.sizex/2,rpos)
|
||||||
|
win5.clrtoeol()
|
||||||
|
win5.box()
|
||||||
|
win5.refresh()
|
||||||
|
time.sleep(0.1)
|
||||||
|
if a == 32:
|
||||||
|
return
|
||||||
|
|
||||||
|
def level_info(win,cm):
|
||||||
|
string = "there are %s zerodays and %s fed(z)" % (cm.gold, cm.ms)
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,3,rpos,string,curses.color_pair(2))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
time.sleep(0.1)
|
||||||
|
string = ">- Go -<"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,6,rpos,string,curses.color_pair(4))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def congrats(win,cm):
|
||||||
|
string = "awesome! u collected enough zerodays"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,3,rpos,string,curses.color_pair(2))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
time.sleep(0.5)
|
||||||
|
if cm.collected<=10:
|
||||||
|
string = "uid=65535(nobody) gid=65535(nobody)"
|
||||||
|
elif cm.collected>=10 and cm.collected <40:
|
||||||
|
string = "uid=8080(www) gid=8080(www)"
|
||||||
|
elif cm.collected>=40 and cm.collected <70:
|
||||||
|
string = "uid=1(operator) gid=1(operator)"
|
||||||
|
elif cm.collected>=70 and cm.collected <100:
|
||||||
|
string = "uid=0(root) gid=0(wheel) groups=0(wheel)"
|
||||||
|
elif cm.collected>=100 and cm.collected <=120:
|
||||||
|
string = "isn't there a remote shell waiting for you?"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=120 and cm.collected <=140:
|
||||||
|
string = "yes. yes. xss is dangerous too"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=140 and cm.collected <=160:
|
||||||
|
string = "moaarr - do u ever considered stop playing?"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=160 and cm.collected <=180:
|
||||||
|
string = "the latest phrack is out! yes!"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=180 and cm.collected <=200:
|
||||||
|
string = "btw. what happened to phrack.ru?!"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=200 and cm.collected <=220:
|
||||||
|
string = "..."
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=220 and cm.collected <=240:
|
||||||
|
string = "strange things happen in the dark edges of the morloch"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
elif cm.collected>=240:
|
||||||
|
string = "ok, i am off have fun!"
|
||||||
|
color=curses.color_pair(2)
|
||||||
|
|
||||||
|
color=curses.color_pair(5)
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,5,rpos,string,color)
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
win.nodelay(0)
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def lost_a_live(win,cm):
|
||||||
|
string = "watch out man!"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,3,rpos,string,curses.color_pair(2))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def start_of_game(win,cm):
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
win.scrollok(1)
|
||||||
|
win.idlok(1)
|
||||||
|
curses.curs_set(1)
|
||||||
|
string = "here u go stranger, u installed ncurses,\nhave a working python interpreter\na fully colorable xterm or rxvt\nsitting at work on a boring monday morning\nTHIS IS THE CHANCE TO FEEL LIKE 1985\n(no matter if u were not born yet)\n\n\nnow, you have 20 levels\ndont worry if u loose a life\nu get new one with 35 exploits collected\n(from now on this is working in RL as well)\nu meet already one of the bad guys\n%s <---- this is what u want to collect\nu move ur ass with the cursors\n\nif ur listening to LCP\nnow is the time to turn it up\nbring da noize\n\n\n(press space)\n\n\n\n\n\n\n" % (chr(163))
|
||||||
|
parts = string.split('\n')
|
||||||
|
xpos=0
|
||||||
|
win.nodelay(1)
|
||||||
|
for ln in parts:
|
||||||
|
if xpos < 14:
|
||||||
|
xpos+=1
|
||||||
|
if xpos>=14:
|
||||||
|
win.scroll(1)
|
||||||
|
win.move(xpos,1)
|
||||||
|
win.clrtoeol()
|
||||||
|
win.box()
|
||||||
|
|
||||||
|
rpos = cm.compute_strpos(win,1,ln)
|
||||||
|
cm.write_window(win,xpos,rpos,ln,curses.color_pair(1))
|
||||||
|
time.sleep(2.0)
|
||||||
|
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
win.box(0,0)
|
||||||
|
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def end_of_game(win,cm):
|
||||||
|
string = "that's it stranger!\nu did it! the game is over\neven the fedz from hell could not stop u!\n\n\ni hope u had fun.\n"
|
||||||
|
parts = string.split('\n')
|
||||||
|
# win.move(0,0)
|
||||||
|
xpos=1
|
||||||
|
for ln in parts:
|
||||||
|
rpos = cm.compute_strpos(win,1,ln)
|
||||||
|
# win.addstr(ln, curses.color_pair(1))
|
||||||
|
cm.write_window(win,xpos,rpos,ln,curses.color_pair(1))
|
||||||
|
time.sleep(2)
|
||||||
|
xpos+=1
|
||||||
|
|
||||||
|
win.nodelay(1)
|
||||||
|
while 1:
|
||||||
|
rc = random.randint(0,10)
|
||||||
|
string = "~~ keep the spirit - hack the planet! ~~"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,5,rpos,string,curses.color_pair(rc))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
time.sleep(0.3)
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def ur_dead(win,cm):
|
||||||
|
string = "dangit! .gov has u!"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,3,rpos,string,curses.color_pair(2))
|
||||||
|
|
||||||
|
string = "# rm -fr /"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,5,rpos,string,curses.color_pair(2))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def pause_game(win,cm):
|
||||||
|
win.nodelay(0)
|
||||||
|
string = "PAUSE"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,3,rpos,string,curses.color_pair(2))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 32:
|
||||||
|
win.erase()
|
||||||
|
return
|
||||||
|
|
||||||
|
def really_quit(win,cm):
|
||||||
|
string = "Quit the game Y/N"
|
||||||
|
rpos = cm.compute_strpos(win,1,string)
|
||||||
|
cm.write_window(win,3,rpos,string,curses.color_pair(2))
|
||||||
|
win.box()
|
||||||
|
win.refresh()
|
||||||
|
while 1:
|
||||||
|
a = win.getch()
|
||||||
|
if a == 110: #110 == n
|
||||||
|
return -1
|
||||||
|
if a == 122 or a ==121 : #122 == z / 121 == y
|
||||||
|
return 1
|
||||||
|
win.erase()
|
||||||
|
|
||||||
BIN
cmatescenes.pyc
Normal file
BIN
cmatescenes.pyc
Normal file
Binary file not shown.
28
levelfile.txt
Normal file
28
levelfile.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#############################################################################
|
||||||
|
#this is the cursedmate level file #
|
||||||
|
#feel free to edit #
|
||||||
|
# #
|
||||||
|
#<lvl><min gold><max gold><min monster><max monster><monster speed> #
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
0,5,5,1,1,1000
|
||||||
|
1,10,15,2,3,1000
|
||||||
|
2,10,20,2,2,500
|
||||||
|
3,15,20,4,4,1000
|
||||||
|
4,10,20,3,3,500
|
||||||
|
5,20,30,5,5,700
|
||||||
|
6,30,30,3,3,100
|
||||||
|
7,20,30,4,5,100
|
||||||
|
8,20,50,7,7,400
|
||||||
|
9,20,50,5,9,400
|
||||||
|
10,15,50,3,10,100
|
||||||
|
11,15,50,4,10,100
|
||||||
|
12,15,50,5,10,100
|
||||||
|
13,15,50,6,10,100
|
||||||
|
14,15,50,7,10,100
|
||||||
|
15,15,50,8,10,100
|
||||||
|
16,15,50,9,10,100
|
||||||
|
17,15,50,10,10,100
|
||||||
|
18,15,50,1,10,100
|
||||||
|
19,15,50,1,10,100
|
||||||
|
20,15,50,1,10,100
|
||||||
Reference in New Issue
Block a user