Adding players base webpage, adding average time to answer question
This commit is contained in:
parent
e6920d67e7
commit
cecd7e94fb
|
|
@ -72,6 +72,7 @@
|
|||
<ul class="nav">
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li><a href="stats.php">Stats</a></li>
|
||||
<li><a href="user.php">Players</a></li>
|
||||
<li><a href="reports.php">Reports</a></li>
|
||||
<li class="active"><a href="about.php">About</a></li>
|
||||
<li><a href="contact.php">Contact</a></li>
|
||||
|
|
@ -82,15 +83,15 @@
|
|||
</div>
|
||||
|
||||
<div class="hero-unit">
|
||||
<h1>About TriviaTime</h1>
|
||||
<p>TriviaTime is a trivia game on IRC, made exclusively for Trivialand.</p>
|
||||
<p>We are #trivialand on Freenode. <a href="irc://chat.freenode.net/trivialand">Come play with us!</a></p>
|
||||
<h1>About Us</h1>
|
||||
<p>TriviaTime is a trivia word game meant for irc. The source code is on github, be sure to check it out.</p>
|
||||
<p>We are #trivialand on Freenode. Come join us!</p>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>© Trivialand 2013 - <a href="https://github.com/tannn/TriviaTime">GitHub</a></p>
|
||||
<p>© Trivialand 2013 - <a href="https://github.com/tannn/TriviaTime">github</a></p>
|
||||
</div>
|
||||
|
||||
</div> <!-- /container -->
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
<ul class="nav">
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li><a href="stats.php">Stats</a></li>
|
||||
<li><a href="user.php">Players</a></li>
|
||||
<li><a href="reports.php">Reports</a></li>
|
||||
<li><a href="about.php">About</a></li>
|
||||
<li class="active"><a href="contact.php">Contact</a></li>
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
<ul class="nav">
|
||||
<li class="active"><a href="index.php">Home</a></li>
|
||||
<li><a href="stats.php">Stats</a></li>
|
||||
<li><a href="user.php">Players</a></li>
|
||||
<li><a href="reports.php">Reports</a></li>
|
||||
<li><a href="about.php">About</a></li>
|
||||
<li><a href="contact.php">Contact</a></li>
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
<ul class="nav">
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li><a href="stats.php">Stats</a></li>
|
||||
<li><a href="user.php">Players</a></li>
|
||||
<li class="active"><a href="reports.php">Reports</a></li>
|
||||
<li><a href="about.php">About</a></li>
|
||||
<li><a href="contact.php">Contact</a></li>
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@
|
|||
<ul class="nav">
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li class="active"><a href="stats.php">Stats</a></li>
|
||||
<li><a href="user.php">Players</a></li>
|
||||
<li><a href="reports.php">Reports</a></li>
|
||||
<li><a href="about.php">About</a></li>
|
||||
<li><a href="contact.php">Contact</a></li>
|
||||
|
|
|
|||
26
plugin.py
26
plugin.py
|
|
@ -60,7 +60,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
self.storage.makeQuestionTable()
|
||||
#self.storage.dropEditTable()
|
||||
self.storage.makeEditTable()
|
||||
#self.storage.insertUserLog('root', 1, 1, 10, 30, 2013)
|
||||
#self.storage.insertUserLog('root', 1, 1, 10, 10, 30, 2013)
|
||||
#self.storage.insertUser('root', 1, 1)
|
||||
|
||||
#filename = self.registryValue('quizfile')
|
||||
|
|
@ -292,7 +292,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
day = d.day
|
||||
month = d.month
|
||||
year = d.year
|
||||
self.storage.updateUserLog(str.lower(username), points, 0, day, month, year)
|
||||
self.storage.updateUserLog(str.lower(username), points, 0, 0, day, month, year)
|
||||
irc.reply('Added %d points to %s' % (points, username))
|
||||
givepoints = wrap(givepoints, ['admin','nick', 'int', optional('int')])
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
|
||||
self.totalAmountWon += pointsAdded
|
||||
# report the correct guess for kaos item
|
||||
self.storage.updateUserLog(username,pointsAdded,0)
|
||||
self.storage.updateUserLog(username,pointsAdded,0, 0)
|
||||
self.lastAnswer = time.time()
|
||||
self.sendMessage(self.registryValue('answeredKAOS', self.channel)
|
||||
% (username, pointsAdded, correctAnswer))
|
||||
|
|
@ -666,7 +666,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
pointsAdded = int(pointsAdded)
|
||||
|
||||
# report correct guess, and show players streak
|
||||
self.storage.updateUserLog(username,pointsAdded,1)
|
||||
self.storage.updateUserLog(username,pointsAdded,1, timeElapsed)
|
||||
self.lastAnswer = time.time()
|
||||
self.sendMessage(self.registryValue('answeredNormal', self.channel)
|
||||
% (username, correctAnswer, timeElapsed, pointsAdded, streakBonus))
|
||||
|
|
@ -698,7 +698,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
bonusPointsText = ''
|
||||
if bonusPoints > 0:
|
||||
for nick in self.correctPlayers:
|
||||
self.storage.updateUserLog(str(username).lower(),bonusPoints)
|
||||
self.storage.updateUserLog(str(username).lower(),bonusPoints, 0, 0)
|
||||
bonusPointsText += self.registryValue('bonusKAOS', self.channel) % int(bonusPoints)
|
||||
|
||||
# give a special message if it was KAOS
|
||||
|
|
@ -1028,7 +1028,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
# otherwise errors
|
||||
self.conn.text_factory = str
|
||||
|
||||
def insertUserLog(self, username, score, numAnswered, day=None, month=None, year=None, epoch=None):
|
||||
def insertUserLog(self, username, score, numAnswered, timeTaken, day=None, month=None, year=None, epoch=None):
|
||||
if day == None and month == None and year == None:
|
||||
dateObject = datetime.date.today()
|
||||
day = dateObject.day
|
||||
|
|
@ -1038,11 +1038,11 @@ class TriviaTime(callbacks.Plugin):
|
|||
if epoch is None:
|
||||
epoch = int(time.mktime(time.localtime()))
|
||||
if self.userLogExists(username, day, month, year):
|
||||
return self.updateUserLog(username, score, day, month, year)
|
||||
return self.updateUserLog(username, score, numAnswered, timeTaken, day, month, year, epoch)
|
||||
c = self.conn.cursor()
|
||||
username = str.lower(username)
|
||||
c.execute('insert into triviauserlog values (NULL, ?, ?, ?, ?, ?, ?, ?)',
|
||||
(username, score, numAnswered, day, month, year, epoch))
|
||||
c.execute('insert into triviauserlog values (NULL, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
(username, score, numAnswered, day, month, year, epoch, timeTaken))
|
||||
self.conn.commit()
|
||||
c.close()
|
||||
|
||||
|
|
@ -1159,7 +1159,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
return True
|
||||
return False
|
||||
|
||||
def updateUserLog(self, username, score, numAnswered, day=None, month=None, year=None, epoch=None):
|
||||
def updateUserLog(self, username, score, numAnswered, timeTaken, day=None, month=None, year=None, epoch=None):
|
||||
username = str.lower(username)
|
||||
if not self.userExists(username):
|
||||
self.insertUser(username)
|
||||
|
|
@ -1171,19 +1171,20 @@ class TriviaTime(callbacks.Plugin):
|
|||
if epoch is None:
|
||||
epoch = int(time.mktime(time.localtime()))
|
||||
if not self.userLogExists(username, day, month, year):
|
||||
return self.insertUserLog(username, score, numAnswered, day, month, year)
|
||||
return self.insertUserLog(username, score, numAnswered, timeTaken, day, month, year, epoch)
|
||||
c = self.conn.cursor()
|
||||
usr = str.lower(username)
|
||||
scr = score
|
||||
numAns = numAnswered
|
||||
test = c.execute('''update triviauserlog set
|
||||
points_made = points_made+?,
|
||||
average_time=( average_time * (1.0*num_answered/(num_answered+?)) + ? * (1.0*?/(num_answered+?)) ),
|
||||
num_answered = num_answered+?,
|
||||
last_updated = ?
|
||||
where username=?
|
||||
and day=?
|
||||
and month=?
|
||||
and year=?''', (scr,numAns,epoch,usr,day,month,year))
|
||||
and year=?''', (scr,numAns,timeTaken,numAns,numAns,numAns,epoch,usr,day,month,year))
|
||||
self.conn.commit()
|
||||
c.close()
|
||||
|
||||
|
|
@ -1307,6 +1308,7 @@ class TriviaTime(callbacks.Plugin):
|
|||
month integer,
|
||||
year integer,
|
||||
last_updated integer,
|
||||
average_time integer,
|
||||
unique(username, day, month, year) on conflict replace
|
||||
)''')
|
||||
except:
|
||||
|
|
|
|||
Loading…
Reference in New Issue