Skip to content

Commit 050ebfb

Browse files
committed
style of dragon
1 parent b950fcf commit 050ebfb

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

dragon.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from sqlalchemy import *
2+
from sqlalchemy.orm import mapper, relation
3+
from sqlalchemy import Table, ForeignKey, Column
4+
from sqlalchemy.types import Integer, Unicode
5+
from sqlalchemy.orm import relation, backref
6+
from stchong.model import DeclarativeBase, metadata, DBSession
7+
8+
class Dragon(DeclarativeBase):
9+
__tablename__ = 'dragon'
10+
#{ Columns uid and pid can pet move from one to others ? if so pid should be independent from user
11+
uid = Column(Integer)#owner
12+
pid = Column(Integer, primary_key=True)#pet id
13+
bid = Column(Integer)
14+
#when move house need to update it ?take it as normal building
15+
#gridId = Column(Integer)#house position also means id
16+
#groundId = Column(Integer)#building id check from businessWrite
17+
18+
#cityId = Column(Integer)
19+
20+
friNum = Column(Integer)#how many friend help or caesars used
21+
#0 not active(need friend help)
22+
#1 active but not buy eggs
23+
#2 egg
24+
#3 child
25+
#4 young
26+
#5 adult
27+
#6 old
28+
#7 dead
29+
state = Column(Integer)
30+
#egg --> 9 if feed +3
31+
#check last login time diftime/24 * -1 when > 30 grow up
32+
#health > 0
33+
34+
#child 25 feed+5 -1 when >= 100
35+
#young +7 -2 250
36+
#600 dead--> -10 + 7
37+
health = Column(Integer)
38+
39+
#default my pet
40+
name = Column(String)
41+
#attribute of dragon
42+
# no att, fire, wind, ice-cream, golden
43+
kind = Column(Integer)#low high kind | clothes
44+
#other attribute
45+
#cur help friend list
46+
friList = Column(Integer)
47+
#0 not feed 1 I feed 2 friend help 3 both
48+
lastFeed = Column(Integer)
49+
50+
attack = Column(Integer)
51+
style = Column(Integer)

root.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4757,8 +4757,13 @@ def getBids(self, uid, cid):
47574757
buildings = DBSession.query(businessWrite.bid, businessWrite.grid_id).filter_by(city_id = cid).all()
47584758
return dict(id=1, bids = buildings)
47594759
@expose('json')
4760+
def changeStyle(self, uid, pid, style):
4761+
dragon = DBSession.query(Dragon).filter_by(pid=pid).one()
4762+
dragon.style = style
4763+
return dict(id=1)
4764+
@expose('json')
47604765
def getPets(self, uid, cid):
4761-
dragon = DBSession.query(Dragon.pid, Dragon.bid, businessWrite.grid_id, Dragon.state, Dragon.kind, Dragon.health, Dragon.friNum, Dragon.friList, Dragon.name, Dragon.attack, Dragon.lastFeed).filter(and_(Dragon.uid == uid, businessWrite.bid==Dragon.bid)).all()#index bid
4766+
dragon = DBSession.query(Dragon.pid, Dragon.bid, businessWrite.grid_id, Dragon.state, Dragon.kind, Dragon.health, Dragon.friNum, Dragon.friList, Dragon.name, Dragon.attack, Dragon.lastFeed, Dragon.style).filter(and_(Dragon.uid == uid, businessWrite.bid==Dragon.bid)).all()#index bid
47624767
allPets = []
47634768
for d in dragon:
47644769
ld = list(d)

0 commit comments

Comments
 (0)