forked from nss-day-cohort-13/birdyboard-castle-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard.py
244 lines (176 loc) · 5.16 KB
/
board.py
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import pickle
import sys
import uuid
from serial import *
from collections import OrderedDict
class Board():
def __init__(self):
self.users = []
self.chirps = []
self.convos = []
# self.chirps = deserializeChirps(self)
# self.user = self.deserializeUser()
# uid = str(uuid.uuid4())
def show_menu(self):
print('what would you like to do?')
print("1. New User Account")
print("2. Select User")
print("3. View Chirps")
print("4. Public Chirp")
print("5. Private Chirp")
print("6. Exit")
user_choice = input(">")
if user_choice == "1":
global userID
deserializeUsers(self)
user = dict()
uid = str(uuid.uuid4())
user[uid] = dict()
print("Create a New Account to get chirpy!.")
inp1 = input("Enter screen name: ")
user[uid]['username'] = inp1
inp2 = input("Enter full name: ")
user[uid]['fullname'] = inp2
self.users.append(user)
serializeUsers(self)
print(self.users)
if user_choice == "2":
deserializeUsers(self)
print("Select a User to chirp it up with!.")
self.showUser()
inp3 = input(">")
userID = self.addUserID(inp3)
print(userID)
if user_choice == "3":
deserializeChirps(self)
deserializeConvos(self)
print("Time to get chirpy! Select any chirp to get chirpin'.")
print('>>>>>PUBLIC<<<<<')
self.showAllPublicChirps()
print('>>>>>PRIVATE<<<<<')
self.showAllPrivateChirps()
inp7 = input(">")
self.addConvoID(inp7)
print(self.addConvoID(inp7))
print(self.chirps)
# print(self.users)
if user_choice == "4":
deserializeChirps(self)
chirp = dict()
uid = str(uuid.uuid4())
chirp[uid] = dict()
print("Write a new public chirp!")
inp4 = input(">")
chirp[uid]['chirp'] = inp4
chirp[uid]['uid'] = userID
chirp[uid]['private'] = False
chirp[uid]['recipient'] = None
self.chirps.append(chirp)
self.createConvos(chirp)
serializeChirps(self)
if user_choice == "5":
deserializeChirps(self)
chirp = dict()
uid = str(uuid.uuid4())
chirp[uid] = dict()
print("Write a new private chirp!")
inp5 = input(">")
chirp[uid]['chirp'] = inp5
chirp[uid]['uid'] = userID
chirp[uid]['private'] = True
print("Who you chirpin at?")
self.showUser()
inp6 = input(">")
userID = self.addUserID(inp6)
chirp[uid]['recipient'] = userID
self.chirps.append(chirp)
self.createConvos(chirp)
serializeChirps(self)
# if user_choice == "7":
# deserializeConvo(self)
# uid = str(uuid.uuid4())
# self.convos[uid] = list()
# self.convos[uid].append(userID)
# serializeConvo(self)
# print(self.convos)
if user_choice != "6":
self.show_menu()
def showUser(self):
u = self.users
for user in u:
for k,v in user.items():
print(v['username'])
def addUserID(self, inp):
u = self.users
for user in u:
for k,v in user.items():
if inp == v['username']:
return k
def showAllPublicChirps(self):
# pubChirps = []
c = self.chirps
for chirp in c:
for k,v in chirp.items():
if v['private'] == False:
print(v['chirp'])
# pubChirps.append(v['chirp'])
# print(pubChirps)
def showAllPrivateChirps(self):
c = self.chirps
for chirp in c:
for k,v in chirp.items():
if v['private'] == True:
print(v['chirp'])
#if return value is of chirp is equal to users
# def checkUserID(self):
# c = self.chirps
# for k,v in c.items():
# if v['uid'] != None and v['recipient'] != None:
# print(v['chirp'])
def addConvoID(self, inp):
c = self.convos
for convo in c:
for k,v in convo.items():
# if inp == v['chirp']:
for x,y in v.items():
if inp == y['chirp']:
return x
def createConvos(self, chirp):
deserializeConvos(self)
convo = dict()
uid = str(uuid.uuid4())
convo[uid] = chirp
self.convos.append(convo)
serializeConvos(self)
# for chirps
# if private = true
# return user id and recipient id
# if user id or recipient id
# equal to input
# and input == user select
# show private chirps
# else if private = false
# show public chirps
# when a chirp is selected return convo uid and display related chirps
#print chirps
#reply - creates a new chirp and appends to list of chirps on convo
#back - returns user to chirp menu
# def x(self):
# deserializeConvo(self)
# c = self.convos
# for k,v in c.items():
# print(k,v)
# Chirps are separated into public and private chirps.
# Only the two users involved in a private chirp can
# see it in their Private Chirps section.
#when a chirp is selected it takes you to that chirp's comment thread.
#Tweedleedee: Anybody know a good Thai restaraunt in the area?
# Fuzzy: Smiling Elephant is really good
# BiffBoffin: The pad krapow is amazing!
# ...
# 1. Reply
# 2. Back
# >
if __name__ == '__main__':
board = Board()
board.show_menu()