Mercurial > sypikslang
changeset 32:00aff02bc6fc
Product categories.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 06 May 2012 20:57:04 +0200 |
parents | 51ff46f42ed2 |
children | 12c33aac7684 |
files | gamelib/missions.py gamelib/products.py |
diffstat | 2 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/missions.py Sun May 06 20:54:03 2012 +0200 +++ b/gamelib/missions.py Sun May 06 20:57:04 2012 +0200 @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4 -from products import DoomsdayVirus, MachineGun, LightningGun +from products import DoomsdayVirus, HAND_WEAPON MAJOR_SETBACK, FAILURE, SUCCESS, MAJOR_SUCCESS, GAME_WIN = range(5) @@ -58,7 +58,7 @@ LONG_DESCRIPTION = ("It's not menancing, or lucrative, but when the bills" " are due, no one cares how you earn the money") - def attempt(sefl, equipment, state): + def attempt(self, equipment, state): return Result(SUCCESS, 100, -1, "You devote your resources to" " robbing kids in a playpark. It's not the finest moment" " in your reign of terror, but at least you walked away" @@ -130,7 +130,7 @@ return Result(SUCCESS, 1000, 0, "Holding up a bank with" " only a small vial of clear liquid. Now that" " is power.") - elif isinstance(item, (MachineGun, LightningGun)): + elif HAND_WEAPON in item.CATEGORIES: return Result(SUCCESS, 1000, 0, "The threat of your weapons is" " enough to inspire an impressive level of cooperation") else:
--- a/gamelib/products.py Sun May 06 20:54:03 2012 +0200 +++ b/gamelib/products.py Sun May 06 20:57:04 2012 +0200 @@ -1,14 +1,22 @@ from gamelib import research +# Kinds of product. +HAND_WEAPON = 'hand weapon' +VEHICLE = 'vehicle' +DOOMSDAY_DEVICE = 'doomsday device' +PATHOGEN = 'pathogen' + + class Product(object): NAME = None PREREQUISITES = () ACQUISITION_CHANCE = 0.8 - COST = 0 + COST = None UPGRADE_REQUIREMENT = 1 STARTING_PRODUCT = False SCIENCE_TYPE = 'product' + CATEGORIES = () def __init__(self, points=0): self.points = points @@ -24,6 +32,7 @@ class MachineGun(Product): NAME = "Machine gun" COST = 100 + CATEGORIES = (HAND_WEAPON,) STARTING_PRODUCT = True def __init__(self, points=0): @@ -38,14 +47,17 @@ class LightningGun(Product): NAME = "Lightning gun" + COST = 300 + CATEGORIES = (HAND_WEAPON,) PREREQUISITES = ( (research.Tesla, 1), ) - COST = 300 class TeslaTank(Product): NAME = "Tesla tank" + COST = 1000 + CATEGORIES = (VEHICLE,) PREREQUISITES = ( (research.Tesla, 3), ) @@ -53,7 +65,8 @@ class DoomsdayVirus(Product): NAME = "Doomsday virus" + COST = 100000 + CATEGORIES = (DOOMSDAY_DEVICE, PATHOGEN) PREREQUISITES = ( (research.Biogenetics, 5), ) - COST = 1000