Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated mrpg.py to reference ttl instead of tonextlevel, added instal…

…l.py to create a sample database file (will need massive changes)
  • Loading branch information...
commit 7f4166e158ccde21c19f3308dfe13e328253470e 1 parent ff911b1
Richard richard4339 authored
Showing with 65 additions and 7 deletions.
  1. +7 −7 mrpg.py
  2. +58 −0 scripts/install.py
14 mrpg.py
View
@@ -67,15 +67,15 @@ def rpg(self):
self.db.shutdown("")
class User:
- def __init__(self, id, username, char_class, password, level, tonextlevel, hostname):
+ def __init__(self, id, username, char_class, password, level, ttl, hostname):
self.username = username
self.char_class = char_class
self.password = password
self.level = level
- self.tonextlevel = tonextlevel
+ self.ttl = ttl
self.hostname = hostname
def render(self):
- msg = "%s %s %s %i %i %s" % (self.username,self.char_class,self.password, self.level, self.tonextlevel, self.hostname)
+ msg = "%s %s %s %i %i %s" % (self.username,self.char_class,self.password, self.level, self.ttl, self.hostname)
return msg
class DBPool:
"""
@@ -97,8 +97,8 @@ def build_user(self, dbentries):
"""
Build user from dbentries
"""
- id, username, password, level, tonextlevel, char_class, hostname = dbentries[0]
- return User(id, username, char_class, password, level, tonextlevel, hostname)
+ id, username, password, level, ttl, char_class, hostname = dbentries[0]
+ return User(id, username, char_class, password, level, ttl, hostname)
def get_user_user(self, username):
"""
Build associated user object
@@ -108,11 +108,11 @@ def get_user_user(self, username):
self.build_user)
def update_user_time(self, username, time):
time = str(time)
- query = 'UPDATE `users` SET tonextlevel = tonextlevel + ' + time + ' where username=?'
+ query = 'UPDATE `users` SET ttl = ttl + ' + time + ' where username=?'
return self.__dbpool.runQuery(query, (username,))
def register_user(self, reg_username, reg_password, reg_char_class):
- query = 'INSERT INTO `users` (id,username,password,level,tonextlevel,char_class,hostname) VALUES (NULL,?,?,NULL,NULL,?,NULL)'
+ query = 'INSERT INTO `users` (id,username,password,level,ttl,char_class,hostname) VALUES (NULL,?,?,NULL,NULL,?,NULL)'
return self.__dbpool.runQuery(query, (reg_username, reg_password, reg_char_class))
58 scripts/install.py
View
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+# mRPG
+# https://github.com/mozor/mRPG
+#
+# Copyright 2012 Greg (NeWtoz@mozor.net) & Richard (richard@mozor.net);
+# This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+# To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to
+# Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
+
+import os.path
+import os
+import shutil
+import sqlite3
+
+path = os.getcwd()
+print path
+db = "mrpg.db"
+config = "config.cfg"
+
+if os.path.isfile(db):
+ print("The database file has already been created.")
+else:
+ open(db, "w").close()
+ print("The empty database file has been created.")
+
+ conn = sqlite3.connect(db)
+
+ c = conn.cursor()
+
+ # Create Users Table
+ c.execute('''CREATE TABLE users
+ (id INTEGER PRIMARY KEY, username TEXT, password TEXT, level NUMERIC, ttl NUMERIC, char_class TEXT, hostname TEXT, online INT, registration_date TEXT DEFAULT CURRENT_TIMESTAMP, last_login TEXT DEFAULT CURRENT_TIMESTAMP)''')
+
+ conn.commit()
+
+ # Create Items Table
+ c.execute('''CREATE TABLE items
+ (id INTEGER PRIMARY KEY, item_name TEXT, item_type TEXT)''')
+
+ conn.commit()
+
+ # Create Events Table
+ c.execute('''CREATE TABLE events
+ (id INTEGER PRIMARY KEY, event_name TEXT, event_type TEXT)''')
+
+ conn.commit()
+
+ # We can also close the cursor if we are done with it
+ c.close()
+
+ print("The database has been created.")
+
+if os.path.isfile(config):
+ print("The config file has already been created.")
+else:
+ shutil.copy2("docs/example.cfg", config)
+ print("Please modify config.cfg before running for the first time.")
Please sign in to comment.
Something went wrong with that request. Please try again.