inital commit

This commit is contained in:
Gesche 2019-01-20 16:48:54 +01:00
commit 44036e57e9
17 changed files with 1110 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea
__pycache__

0
accounts/__init__.py Normal file
View File

25
accounts/admin.py Normal file
View File

@ -0,0 +1,25 @@
from django.contrib import admin
from .models import Accounts, Players, Towns
class AccountsAdmin(admin.ModelAdmin):
list_display = ('name',)
fields = ['name', 'password', 'type', 'email']
class PlayersAdmin(admin.ModelAdmin):
list_display = ('name', 'account',)
fields = [
'name', 'group_id', 'account', 'level', 'vocation',
'health', 'healthmax', 'maglevel', 'mana', 'manamax',
'town_id', 'posx', 'posy', 'posz', 'cap', 'sex', 'balance',
'skill_fist', 'skill_club', 'skill_sword', 'skill_axe',
'skill_dist', 'skill_shielding',
'skill_fishing',
]
class TownsAdmin(admin.ModelAdmin):
list_display = ('name',)
admin.site.register(Accounts, AccountsAdmin)
admin.site.register(Players, PlayersAdmin)
admin.site.register(Towns, TownsAdmin)

5
accounts/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'

View File

@ -0,0 +1,436 @@
# Generated by Django 2.1.5 on 2019-01-20 14:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='AccountBanHistory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reason', models.CharField(max_length=255)),
('banned_at', models.BigIntegerField()),
('expired_at', models.BigIntegerField()),
],
options={
'db_table': 'account_ban_history',
'managed': False,
},
),
migrations.CreateModel(
name='Accounts',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=32, unique=True)),
('password', models.CharField(max_length=40)),
('secret', models.CharField(blank=True, max_length=16, null=True)),
('type', models.IntegerField()),
('premdays', models.IntegerField()),
('lastday', models.PositiveIntegerField()),
('email', models.CharField(max_length=255)),
('creation', models.IntegerField()),
],
options={
'db_table': 'accounts',
'managed': False,
},
),
migrations.CreateModel(
name='AccountViplist',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('description', models.CharField(max_length=128)),
('icon', models.PositiveIntegerField()),
('notify', models.IntegerField()),
],
options={
'db_table': 'account_viplist',
'managed': False,
},
),
migrations.CreateModel(
name='GuildRanks',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('level', models.IntegerField()),
],
options={
'db_table': 'guild_ranks',
'managed': False,
},
),
migrations.CreateModel(
name='Guilds',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('creationdata', models.IntegerField()),
('motd', models.CharField(max_length=255)),
],
options={
'db_table': 'guilds',
'managed': False,
},
),
migrations.CreateModel(
name='GuildwarKills',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('killer', models.CharField(max_length=50)),
('target', models.CharField(max_length=50)),
('killerguild', models.IntegerField()),
('targetguild', models.IntegerField()),
('time', models.BigIntegerField()),
],
options={
'db_table': 'guildwar_kills',
'managed': False,
},
),
migrations.CreateModel(
name='GuildWars',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('guild1', models.IntegerField()),
('guild2', models.IntegerField()),
('name1', models.CharField(max_length=255)),
('name2', models.CharField(max_length=255)),
('status', models.IntegerField()),
('started', models.BigIntegerField()),
('ended', models.BigIntegerField()),
],
options={
'db_table': 'guild_wars',
'managed': False,
},
),
migrations.CreateModel(
name='HouseLists',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('listid', models.IntegerField()),
('list', models.TextField()),
],
options={
'db_table': 'house_lists',
'managed': False,
},
),
migrations.CreateModel(
name='Houses',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('owner', models.IntegerField()),
('paid', models.PositiveIntegerField()),
('warnings', models.IntegerField()),
('name', models.CharField(max_length=255)),
('rent', models.IntegerField()),
('town_id', models.IntegerField()),
('bid', models.IntegerField()),
('bid_end', models.IntegerField()),
('last_bid', models.IntegerField()),
('highest_bidder', models.IntegerField()),
('size', models.IntegerField()),
('beds', models.IntegerField()),
],
options={
'db_table': 'houses',
'managed': False,
},
),
migrations.CreateModel(
name='IpBans',
fields=[
('ip', models.PositiveIntegerField(primary_key=True, serialize=False)),
('reason', models.CharField(max_length=255)),
('banned_at', models.BigIntegerField()),
('expires_at', models.BigIntegerField()),
],
options={
'db_table': 'ip_bans',
'managed': False,
},
),
migrations.CreateModel(
name='MarketHistory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sale', models.IntegerField()),
('itemtype', models.PositiveIntegerField()),
('amount', models.PositiveSmallIntegerField()),
('price', models.PositiveIntegerField()),
('expires_at', models.BigIntegerField()),
('inserted', models.BigIntegerField()),
('state', models.PositiveIntegerField()),
],
options={
'db_table': 'market_history',
'managed': False,
},
),
migrations.CreateModel(
name='MarketOffers',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sale', models.IntegerField()),
('itemtype', models.PositiveIntegerField()),
('amount', models.PositiveSmallIntegerField()),
('created', models.BigIntegerField()),
('anonymous', models.IntegerField()),
('price', models.PositiveIntegerField()),
],
options={
'db_table': 'market_offers',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerDeaths',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('time', models.BigIntegerField()),
('level', models.IntegerField()),
('killed_by', models.CharField(max_length=255)),
('is_player', models.IntegerField()),
('mostdamage_by', models.CharField(max_length=100)),
('mostdamage_is_player', models.IntegerField()),
('unjustified', models.IntegerField()),
('mostdamage_unjustified', models.IntegerField()),
],
options={
'db_table': 'player_deaths',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerDepotitems',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sid', models.IntegerField()),
('pid', models.IntegerField()),
('itemtype', models.SmallIntegerField()),
('count', models.SmallIntegerField()),
('attributes', models.TextField()),
],
options={
'db_table': 'player_depotitems',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerInboxitems',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sid', models.IntegerField()),
('pid', models.IntegerField()),
('itemtype', models.SmallIntegerField()),
('count', models.SmallIntegerField()),
('attributes', models.TextField()),
],
options={
'db_table': 'player_inboxitems',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerItems',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('pid', models.IntegerField()),
('sid', models.IntegerField()),
('itemtype', models.SmallIntegerField()),
('count', models.SmallIntegerField()),
('attributes', models.TextField()),
],
options={
'db_table': 'player_items',
'managed': False,
},
),
migrations.CreateModel(
name='Players',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('group_id', models.IntegerField()),
('level', models.IntegerField()),
('vocation', models.IntegerField()),
('health', models.IntegerField()),
('healthmax', models.IntegerField()),
('experience', models.BigIntegerField()),
('lookbody', models.IntegerField()),
('lookfeet', models.IntegerField()),
('lookhead', models.IntegerField()),
('looklegs', models.IntegerField()),
('looktype', models.IntegerField()),
('lookaddons', models.IntegerField()),
('maglevel', models.IntegerField()),
('mana', models.IntegerField()),
('manamax', models.IntegerField()),
('manaspent', models.PositiveIntegerField()),
('soul', models.PositiveIntegerField()),
('town_id', models.IntegerField()),
('posx', models.IntegerField()),
('posy', models.IntegerField()),
('posz', models.IntegerField()),
('conditions', models.TextField()),
('cap', models.IntegerField()),
('sex', models.IntegerField()),
('lastlogin', models.BigIntegerField()),
('lastip', models.PositiveIntegerField()),
('save', models.IntegerField()),
('skull', models.IntegerField()),
('skulltime', models.IntegerField()),
('lastlogout', models.BigIntegerField()),
('blessings', models.IntegerField()),
('onlinetime', models.IntegerField()),
('deletion', models.BigIntegerField()),
('balance', models.BigIntegerField()),
('offlinetraining_time', models.PositiveSmallIntegerField()),
('offlinetraining_skill', models.IntegerField()),
('stamina', models.PositiveSmallIntegerField()),
('skill_fist', models.PositiveIntegerField()),
('skill_fist_tries', models.BigIntegerField()),
('skill_club', models.PositiveIntegerField()),
('skill_club_tries', models.BigIntegerField()),
('skill_sword', models.PositiveIntegerField()),
('skill_sword_tries', models.BigIntegerField()),
('skill_axe', models.PositiveIntegerField()),
('skill_axe_tries', models.BigIntegerField()),
('skill_dist', models.PositiveIntegerField()),
('skill_dist_tries', models.BigIntegerField()),
('skill_shielding', models.PositiveIntegerField()),
('skill_shielding_tries', models.BigIntegerField()),
('skill_fishing', models.PositiveIntegerField()),
('skill_fishing_tries', models.BigIntegerField()),
],
options={
'db_table': 'players',
'managed': False,
},
),
migrations.CreateModel(
name='PlayersOnline',
fields=[
('player_id', models.IntegerField(primary_key=True, serialize=False)),
],
options={
'db_table': 'players_online',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerSpells',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
],
options={
'db_table': 'player_spells',
'managed': False,
},
),
migrations.CreateModel(
name='ServerConfig',
fields=[
('config', models.CharField(max_length=50, primary_key=True, serialize=False)),
('value', models.CharField(max_length=256)),
],
options={
'db_table': 'server_config',
'managed': False,
},
),
migrations.CreateModel(
name='TileStore',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('data', models.TextField()),
],
options={
'db_table': 'tile_store',
'managed': False,
},
),
migrations.CreateModel(
name='Towns',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, unique=True)),
('posx', models.IntegerField()),
('posy', models.IntegerField()),
('posz', models.IntegerField()),
],
options={
'db_table': 'towns',
'managed': False,
},
),
migrations.CreateModel(
name='AccountBans',
fields=[
('account', models.OneToOneField(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='accounts.Accounts')),
('reason', models.CharField(max_length=255)),
('banned_at', models.BigIntegerField()),
('expires_at', models.BigIntegerField()),
],
options={
'db_table': 'account_bans',
'managed': False,
},
),
migrations.CreateModel(
name='GuildInvites',
fields=[
('player', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='accounts.Players')),
],
options={
'db_table': 'guild_invites',
'managed': False,
},
),
migrations.CreateModel(
name='GuildMembership',
fields=[
('player', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='accounts.Players')),
('nick', models.CharField(max_length=15)),
],
options={
'db_table': 'guild_membership',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerNamelocks',
fields=[
('player', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='accounts.Players')),
('reason', models.CharField(max_length=255)),
('namelocked_at', models.BigIntegerField()),
],
options={
'db_table': 'player_namelocks',
'managed': False,
},
),
migrations.CreateModel(
name='PlayerStorage',
fields=[
('player', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='accounts.Players')),
('key', models.PositiveIntegerField()),
('value', models.IntegerField()),
],
options={
'db_table': 'player_storage',
'managed': False,
},
),
]

View File

384
accounts/models.py Normal file
View File

@ -0,0 +1,384 @@
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
class AccountBanHistory(models.Model):
account = models.ForeignKey('Accounts', models.DO_NOTHING)
reason = models.CharField(max_length=255)
banned_at = models.BigIntegerField()
expired_at = models.BigIntegerField()
banned_by = models.ForeignKey('Players', models.DO_NOTHING, db_column='banned_by')
class Meta:
managed = False
db_table = 'account_ban_history'
class AccountBans(models.Model):
account = models.OneToOneField('Accounts', models.DO_NOTHING, primary_key=True)
reason = models.CharField(max_length=255)
banned_at = models.BigIntegerField()
expires_at = models.BigIntegerField()
banned_by = models.ForeignKey('Players', models.DO_NOTHING, db_column='banned_by')
class Meta:
managed = False
db_table = 'account_bans'
class AccountViplist(models.Model):
account = models.ForeignKey('Accounts', models.DO_NOTHING)
player = models.ForeignKey('Players', models.DO_NOTHING)
description = models.CharField(max_length=128)
icon = models.PositiveIntegerField()
notify = models.IntegerField()
class Meta:
managed = False
db_table = 'account_viplist'
unique_together = (('account', 'player'),)
class Accounts(models.Model):
name = models.CharField(unique=True, max_length=32)
password = models.CharField(max_length=40)
secret = models.CharField(max_length=16, blank=True, null=True)
type = models.IntegerField(default=1)
premdays = models.IntegerField(default=0)
lastday = models.PositiveIntegerField(default=0)
email = models.CharField(max_length=255)
creation = models.IntegerField(default=0)
class Meta:
managed = False
db_table = 'accounts'
class GuildInvites(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING, primary_key=True)
guild = models.ForeignKey('Guilds', models.DO_NOTHING)
class Meta:
managed = False
db_table = 'guild_invites'
unique_together = (('player', 'guild'),)
class GuildMembership(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING, primary_key=True)
guild = models.ForeignKey('Guilds', models.DO_NOTHING)
rank = models.ForeignKey('GuildRanks', models.DO_NOTHING)
nick = models.CharField(max_length=15)
class Meta:
managed = False
db_table = 'guild_membership'
class GuildRanks(models.Model):
guild = models.ForeignKey('Guilds', models.DO_NOTHING)
name = models.CharField(max_length=255)
level = models.IntegerField()
class Meta:
managed = False
db_table = 'guild_ranks'
class GuildWars(models.Model):
guild1 = models.IntegerField()
guild2 = models.IntegerField()
name1 = models.CharField(max_length=255)
name2 = models.CharField(max_length=255)
status = models.IntegerField()
started = models.BigIntegerField()
ended = models.BigIntegerField()
class Meta:
managed = False
db_table = 'guild_wars'
class Guilds(models.Model):
name = models.CharField(unique=True, max_length=255)
ownerid = models.ForeignKey('Players', models.DO_NOTHING, db_column='ownerid', unique=True)
creationdata = models.IntegerField()
motd = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'guilds'
class GuildwarKills(models.Model):
killer = models.CharField(max_length=50)
target = models.CharField(max_length=50)
killerguild = models.IntegerField()
targetguild = models.IntegerField()
warid = models.ForeignKey(GuildWars, models.DO_NOTHING, db_column='warid')
time = models.BigIntegerField()
class Meta:
managed = False
db_table = 'guildwar_kills'
class HouseLists(models.Model):
house = models.ForeignKey('Houses', models.DO_NOTHING)
listid = models.IntegerField()
list = models.TextField()
class Meta:
managed = False
db_table = 'house_lists'
class Houses(models.Model):
owner = models.IntegerField()
paid = models.PositiveIntegerField()
warnings = models.IntegerField()
name = models.CharField(max_length=255)
rent = models.IntegerField()
town_id = models.IntegerField()
bid = models.IntegerField()
bid_end = models.IntegerField()
last_bid = models.IntegerField()
highest_bidder = models.IntegerField()
size = models.IntegerField()
beds = models.IntegerField()
class Meta:
managed = False
db_table = 'houses'
class IpBans(models.Model):
ip = models.PositiveIntegerField(primary_key=True)
reason = models.CharField(max_length=255)
banned_at = models.BigIntegerField()
expires_at = models.BigIntegerField()
banned_by = models.ForeignKey('Players', models.DO_NOTHING, db_column='banned_by')
class Meta:
managed = False
db_table = 'ip_bans'
class MarketHistory(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
sale = models.IntegerField()
itemtype = models.PositiveIntegerField()
amount = models.PositiveSmallIntegerField()
price = models.PositiveIntegerField()
expires_at = models.BigIntegerField()
inserted = models.BigIntegerField()
state = models.PositiveIntegerField()
class Meta:
managed = False
db_table = 'market_history'
class MarketOffers(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
sale = models.IntegerField()
itemtype = models.PositiveIntegerField()
amount = models.PositiveSmallIntegerField()
created = models.BigIntegerField()
anonymous = models.IntegerField()
price = models.PositiveIntegerField()
class Meta:
managed = False
db_table = 'market_offers'
class PlayerDeaths(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
time = models.BigIntegerField()
level = models.IntegerField()
killed_by = models.CharField(max_length=255)
is_player = models.IntegerField()
mostdamage_by = models.CharField(max_length=100)
mostdamage_is_player = models.IntegerField()
unjustified = models.IntegerField()
mostdamage_unjustified = models.IntegerField()
class Meta:
managed = False
db_table = 'player_deaths'
class PlayerDepotitems(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
sid = models.IntegerField()
pid = models.IntegerField()
itemtype = models.SmallIntegerField()
count = models.SmallIntegerField()
attributes = models.TextField()
class Meta:
managed = False
db_table = 'player_depotitems'
unique_together = (('player', 'sid'),)
class PlayerInboxitems(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
sid = models.IntegerField()
pid = models.IntegerField()
itemtype = models.SmallIntegerField()
count = models.SmallIntegerField()
attributes = models.TextField()
class Meta:
managed = False
db_table = 'player_inboxitems'
unique_together = (('player', 'sid'),)
class PlayerItems(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
pid = models.IntegerField()
sid = models.IntegerField()
itemtype = models.SmallIntegerField()
count = models.SmallIntegerField()
attributes = models.TextField()
class Meta:
managed = False
db_table = 'player_items'
class PlayerNamelocks(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING, primary_key=True)
reason = models.CharField(max_length=255)
namelocked_at = models.BigIntegerField()
namelocked_by = models.ForeignKey('Players', models.DO_NOTHING, db_column='namelocked_by', related_name='namelocks')
class Meta:
managed = False
db_table = 'player_namelocks'
class PlayerSpells(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING)
name = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'player_spells'
class PlayerStorage(models.Model):
player = models.ForeignKey('Players', models.DO_NOTHING, primary_key=True)
key = models.PositiveIntegerField()
value = models.IntegerField()
class Meta:
managed = False
db_table = 'player_storage'
unique_together = (('player', 'key'),)
class Players(models.Model):
name = models.CharField(unique=True, max_length=255)
group_id = models.IntegerField()
account = models.ForeignKey(Accounts, models.DO_NOTHING)
level = models.IntegerField()
vocation = models.IntegerField()
health = models.IntegerField()
healthmax = models.IntegerField()
experience = models.BigIntegerField()
lookbody = models.IntegerField()
lookfeet = models.IntegerField()
lookhead = models.IntegerField()
looklegs = models.IntegerField()
looktype = models.IntegerField()
lookaddons = models.IntegerField()
maglevel = models.IntegerField()
mana = models.IntegerField()
manamax = models.IntegerField()
manaspent = models.PositiveIntegerField()
soul = models.PositiveIntegerField()
town_id = models.IntegerField()
posx = models.IntegerField()
posy = models.IntegerField()
posz = models.IntegerField()
conditions = models.TextField()
cap = models.IntegerField()
sex = models.IntegerField()
lastlogin = models.BigIntegerField()
lastip = models.PositiveIntegerField()
save = models.IntegerField()
skull = models.IntegerField()
skulltime = models.IntegerField()
lastlogout = models.BigIntegerField()
blessings = models.IntegerField()
onlinetime = models.IntegerField()
deletion = models.BigIntegerField()
balance = models.BigIntegerField()
offlinetraining_time = models.PositiveSmallIntegerField()
offlinetraining_skill = models.IntegerField()
stamina = models.PositiveSmallIntegerField()
skill_fist = models.PositiveIntegerField()
skill_fist_tries = models.BigIntegerField()
skill_club = models.PositiveIntegerField()
skill_club_tries = models.BigIntegerField()
skill_sword = models.PositiveIntegerField()
skill_sword_tries = models.BigIntegerField()
skill_axe = models.PositiveIntegerField()
skill_axe_tries = models.BigIntegerField()
skill_dist = models.PositiveIntegerField()
skill_dist_tries = models.BigIntegerField()
skill_shielding = models.PositiveIntegerField()
skill_shielding_tries = models.BigIntegerField()
skill_fishing = models.PositiveIntegerField()
skill_fishing_tries = models.BigIntegerField()
class Meta:
managed = False
db_table = 'players'
class PlayersOnline(models.Model):
player_id = models.IntegerField(primary_key=True)
class Meta:
managed = False
db_table = 'players_online'
class ServerConfig(models.Model):
config = models.CharField(primary_key=True, max_length=50)
value = models.CharField(max_length=256)
class Meta:
managed = False
db_table = 'server_config'
class TileStore(models.Model):
house = models.ForeignKey(Houses, models.DO_NOTHING)
data = models.TextField()
class Meta:
managed = False
db_table = 'tile_store'
class Towns(models.Model):
name = models.CharField(unique=True, max_length=255)
posx = models.IntegerField()
posy = models.IntegerField()
posz = models.IntegerField()
class Meta:
managed = False
db_table = 'towns'

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Highscore</title>
</head>
<body>
{% if best_players %}
<ul>
{% for player in best_players %}
<li>{{ player.name }} - {{ player.level }}</li>
{% endfor %}
</ul>
{% else %}
<p>No players registered.</p>
{% endif %}
<a href="{% url 'accounts:register' %}">Register now!</a>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Register Account</title>
</head>
<body>
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save">
</form>
</body>
</html>

3
accounts/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

11
accounts/urls.py Normal file
View File

@ -0,0 +1,11 @@
from django.urls import path
from . import views
app_name = 'accounts'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('register/', views.RegisterAccountView.as_view(), name='register'),
]

27
accounts/views.py Normal file
View File

@ -0,0 +1,27 @@
from django.shortcuts import render, render_to_response
from django.views import generic
from django.views.generic.edit import CreateView
# Create your views here.
from accounts.models import Accounts, Players
class RegisterAccountView(CreateView):
model = Accounts
fields = ['name', 'password', 'email']
template_name = 'register_account.html'
def form_valid(self, form):
import hashlib
self.object = form.save(commit=False)
hashed_password = hashlib.sha1(self.object.password.encode('utf-8')).hexdigest()
self.object.password = hashed_password
self.object.save()
return render_to_response(self.template_name, self.get_context_data())
class IndexView(generic.ListView):
template_name = 'index.html'
context_object_name = 'best_players'
def get_queryset(self):
return Players.objects.order_by('-level')[:10]

15
manage.py Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tibia_website.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

View File

125
tibia_website/settings.py Normal file
View File

@ -0,0 +1,125 @@
"""
Django settings for tibia_website project.
Generated by 'django-admin startproject' using Django 2.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0bup5^j9qen7!g8i5ngkc0_n+0wh@8n8j@_j+$vj06l3v2)esl'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'accounts.apps.AccountsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'tibia_website.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'tibia_website.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'tibia3',
'USER': 'tibia',
'PASSWORD': 'dVS5iy3R7Q9kMZd7',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'

22
tibia_website/urls.py Normal file
View File

@ -0,0 +1,22 @@
"""tibia_website URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('accounts.urls') )
]

16
tibia_website/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for tibia_website project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tibia_website.settings')
application = get_wsgi_application()