forked from TimeEnjoyed/TimeToGrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.txt
More file actions
203 lines (160 loc) · 4.64 KB
/
notes.txt
File metadata and controls
203 lines (160 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
===================================================================
BASIC EXAMPLE
- USER BUYS SEEDS WITH POINTS (50pts) (twitchapi <-websocket-> twitchio)
- (twitchio <-built into each other-> starlette server)
- Creates user in table in database. (sqlite - asynchronous via wrapper https://github.com/Rapptz/asqlite)
- Questions: attributes of user?
- Grab seeds.jpg and display on template.
===================================================================
Three parts
1) This should work from command line- Growth Plant Program (state)
2) The Server Problem - connect user to program
twitchAPI - connects to events such as: redemption points, follows, subs
3) How to display via HTML
-prob need js
starlette receives the request into a function.
def receive_redemption(?)
# create user in database
# returns user object
Process/thinking aloud:
- redeem event --> request ( username, type of redemption) POST.
- Server Side Event
User on Twitch Redeems > TwitchIO Recieves Redemption >
TwitchIO does whatever you want with API and puts data into queue >
Starlette receives data from queue >
Starlette sends an event to all subscribed listeners
===============================
Feature creep:
- refund redmptions that dont work
- create customredemptions
- delete customredemptions
===============================
TODO:
[x] - finish database
[x] - if null exists
CREATE TABLE IF NOT EXISTS plants (
rowid INTEGER PRIMARY KEY,
username TEXT,
cycle INT,
water BOOLEAN,
sabotage BOOLEAN,
growth_cycles INT
);
growth_cycles: int = 1 - 8
1 - mound
2 - sprout
3 - seedling
4 - 2 leaves
5 - higher
6 - little bud
7 - starting to bloom
8 - full bloom
# TO GET THE CYCLE
[timeenjoyed]
- twitchio.routines (sends to frontend every 6 mins)
- automatic
**** ADDED ****
- need to pull all the rows that have water = False and update their cycle and growth_cycle to reflect missing a water cycle
[bunnie] - cycle: int = 1 2 3 4
1 grow
2 water
1) water= True > 1;
2) water=False -> 3
3 waits for water.
1) water = True > 2;
2) water= False -> 4
4 death
- if someone waters their plant first, and then it gets sabotaged = cycle doens't change
1, cycle = 2, water = False
2, cycle = 2, water = True, sabotage = True
3, cycle = 2, water = False, sabotage = False
^ user needs to water again
- if someone sabotages first, then waters it = -1 cycle
[] - twitchio.routines (sends to frontend every 1 min)
- triggered
[bunnie] - function that responds to water-text command
[x] - sabotage - functions that responds
SABOTAGE (redemption):
- anyone can sabotage
- non-followers: return "you need to be a follower", reject/refund
- follower
- bot runs sabotage() -> auto completes redemption
PLANT+WATER SEED (redemption):
- anyone can plant seed
- non-followers: return "you need to be a follower", reject/refund
- follower
- bot runs sabotage() -> auto completes redemption
WATER (command):
- non-follower: bot passes
- follower: bot sends info to water()
WILT
- if someone doesn't water when 6 min < cycle < 12min:
- state for plant: -1? ??
- shows yellow version of plant?
LOGIC in BACK:
user: str = 'timeenjoyed'
rowid: int = 1 # 1-25
water: bool = True
cycle: int = 1 # 1-4
sabotage: bool = True
growth_cycles: int = 1 - 8
- database
[
{
"rowid": 1,
"username": "John",
"water": 25,
"cycle": null,
"sabotage": True,
growth_cycles = 1
},
{
"rowid": 2,
"username": "John",
"water": 25,
"cycle": null,
"sabotage": True,
growth_cycles = 1
},
{
"rowid": 3,
"username": "John",
"water": 25,
"cycle": null,
"sabotage": True,
growth_cycles = 1
},...
]
<script>
cont event = new EventSource("") = > json data
def event
</script>
<html>
<div id=1, style="bottom: 25px'>
<src img="seed.jpg">
</div>
</html>
async def get_step(username):
- "check to see if username exists"
def check_wilt(time)
- "check to see if wilt"
- get time
- generate the state
return state
async def dispatch
========== new approach ==========
Once someone plants a seed, a 6-minute routine begins.
> guaranteed ping to the front
- grow
- dies
And a 1-minute by minute routine begins.
> pings when:
- born
- water
- sabotage
json example:
{ 'ground':
{
'username': username, # '' or 'timenejoyed'
'
}