Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Commit

Permalink
Some helloween
Browse files Browse the repository at this point in the history
  • Loading branch information
YogurtTheHorse committed Oct 29, 2016
1 parent 7a5b683 commit f80fa5d
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 0 deletions.
6 changes: 6 additions & 0 deletions databasemanager/leaderboard_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from mongothon import create_model
from mongothon.validators import one_of

from utils import costumes

ROOMS_TABLE = 'rooms'
KILLS_TABLE = 'kills'
GNOME_TABLE = 'gnome'
Expand Down Expand Up @@ -66,6 +68,10 @@ def sort_by_score(doc):
@Scores.class_method
def add_to_leaderboard(cls, user, score, leaderboard_name='rooms'):
name = user.name

costume = costumes.get_costume(user.costume)
name += ' в костюме _{0}_'.format(costume['who'])

if user.pet:
pet = user.get_pet()
name += ' и {0} {1}'.format(pet.name, pet.real_name)
Expand Down
35 changes: 35 additions & 0 deletions items/special/candy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import random

from utils.buffs import DiabetBuff

name = 'Конфетка'
description = (
'Сладкая и вкусная'
)

price = 1

usable = True
disposable = True

def on_use(user, reply):
cnt = user.get_variable('candies_eat', 0)

if cnt == 10:
reply('Поздравляю, у вас диабет!')
reply('Вот вам конфетка без сахара, чтобы утешить себя')

user.new_buff(DiabetBuff())
user.add_item('special', 'candy')
elif cnt == 11:
reply('А нет, это с сахаром :(\nВот вам другая.')
user.add_item('special', 'candy')
user.make_damage(3, 7, reply, name='Диабет')
elif cnt > 11:
reply('Ну что же вы себя убиваете, голубчик!')
user.make_damage(cnt - 5, cnt + 3, reply, name='Диабет')
else:
reply('Вкусненько!')
user.heal(15)

user.get_variable('candies_eat', cnt + 1)
22 changes: 22 additions & 0 deletions items/special/pumpkin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import random

name = 'Тыква'
description = (
'Праздник к нам приходит, праздник к нам приходит!'
)

price = 3

fightable = True
strengthoff = True
disposable = True

def fight_use(user, reply, room):
reply('Не фашисты, но гранату получат.')

user.make_damage(0, 20, reply, name='Тыква')

if user.dead:
return 0

return random.range(50, 70)
47 changes: 47 additions & 0 deletions rooms/default/special/helloween_shop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import random
from items import itemloader
from utils import costumes

name = 'Зуллуинский магазин'

ACTIONS = [ 'Тыква', 'Костюм', 'Конфета' ]

def enter(user, reply):
reply(
'Какие-то странные бездедушки, черепа и прочая ересь.\n'
'Рука невольно тянется к ручки двери, чтобы сбежать, но '
'какая-та улыбчивая тварь пригласила тебя внутрь и предлагает тебе взять что-то одно, но зато *абсолютно* бесплатно.'
)

user.set_room_temp('costume', costumes.rand_costume_key())

def get_actions(user):
return ACTIONS

def action(user, reply, text):
if text == ACTIONS[0]:
reply('Держи!', photo='BQADAgAD7QgAAmrZzgfDVlphbK6MlgI')
user.add_item('special', 'pumpkin')
user.leave(reply)
elif text == 'Свечка':
reply('Держи свечу, не обожгись!')
user.add_item('special', 'candle')
user.leave(reply)
elif text == ACTIONS[1]:
key = user.get_room_temp('costume', 'none')
costume = costumes.get_costume(key)

user.costume = key

reply('Держи этот шикарный костюм!')
reply('_Вы надеваете костюм {0}_'.format(costume['who']))
reply(costume['description'])
elif text == ACTIONS[2]:
reply('Забирай, но не переедай!')

user.add_item('special', 'candy')
else:
reply('Не понял сейчас')
return

user.leave(reply)
6 changes: 6 additions & 0 deletions user/corridor_defenition.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def open_corridor(self, reply):
if not self.prayed:
buttons.append(locale_manager.get('PRAY_TO_GOD'))

if not self.get_variable('halloween_visited', False):
buttons.append('Хеллуин!')

if not self.visited_shop:
buttons.append(locale_manager.get('OPEN_SHOP'))

Expand Down Expand Up @@ -64,6 +67,9 @@ def corridor(self, reply, text):
self.open_inventory(reply)
elif text.startswith(locale_manager.get('PLAYER_CHARACTERISTICS').split()[0]):
self.show_characteristics(reply)
elif text == 'Хеллуин!' and not self.get_variable('halloween_visited', False):
self.open_room(reply, 'special', 'helloween_shop')
self.set_variable('halloween_visited', True)
elif text == 'Умереть':
reply('Пакеда!', photo='BQADAgAD5wgAAmrZzgcHFvPa24KvDwI')
self.death(reply, reason='Суицид')
Expand Down
3 changes: 3 additions & 0 deletions user/room_defenition.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def get_room_temp(self, name, def_val=None):
return def_val

def open_room(self, reply, room_type=None, room_name=None):
if room_name != 'halloween_shop':
self.set_variable('halloween_visited', False)

if self.race == RAT_RACE:
reply('Ты — крыса, у тебя не хватило сил сдвинуть дверь с места :(')
self.open_corridor(reply)
Expand Down
7 changes: 7 additions & 0 deletions utils/buffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def on_room(self, user, reply, room):
user.make_damage(10, 20, reply, death=True, name='Праведный огонь')
reply('У тебя кожа горит.')

class DiabetBuff(Buff):
def __init__(self):
super(DiabetBuff, self).__init__(3, name='diabet')
def on_room(self, user, reply, room):
user.make_damage(10, 20, reply, death=True, name='Диабет')
reply('Что-то сухо во рту.')

def is_negative(self):
return True

Expand Down
48 changes: 48 additions & 0 deletions utils/costumes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import random

COSTUMES = {
'mexican': {
'who': 'Мексиканского рестлера',
'description': 'Надевая костюм, ты почувствовал как кокс, оставшийся на одежде, попадает в твое тело и ты наполняешься силой.'
},
'ghost': {
'who': 'Призрака',
'description': 'Простыня все еще в моде!'
},
'sceleton': {
'who': 'Скелета',
'description': 'С чем стирать и материал не уточняются.. Но выглядят прямо как настоящие! Жуть.'
},
'fox': {
'who': 'Лисички',
'description': 'Этот хвост так интересно крепится!'
},
'headless': {
'who': 'Всадника без головы',
'description': 'Стало легче выпря млять спину, но теперь ты видишь всё так, будто глаза на уровне пупка.'
},
'zombie': {
'who': 'Зомби',
'description': 'Весь в блювотине, но перфоманс того требует.'
},
'wizzard': {
'who': 'Волшебника',
'description': 'Колпак и палочка Гарри Поттера, которого избили и выкинули в канаву.'
},
'none': {
'who': 'Самого себя',
'description': 'Так себе конечно. Одел бы нижнее белье хотя бы'
}
}

def rand_costume_key():
return random.choice(list(COSTUMES))

def rand_costume():
return get_costume(rand_costume_key())

def get_costume(key):
if key in COSTUMES:
return COSTUMES[key]
else:
return COSTUMES['none']

0 comments on commit f80fa5d

Please sign in to comment.