Skip to content

Instantly share code, notes, and snippets.

@sgtlaggy
Last active August 6, 2017 00:00
Show Gist options
  • Save sgtlaggy/99b642e633c4a27499c11bc58cb376e4 to your computer and use it in GitHub Desktop.
Save sgtlaggy/99b642e633c4a27499c11bc58cb376e4 to your computer and use it in GitHub Desktop.
I wrote DRPG a while back, it was on Github for a bit, then I took it down when I built it into my flask project, which I'm no longer hosting.
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
<link type="text/css" rel="stylesheet" href="/style.css">
{% block head %}{% endblock %}
</head>
<body>
<div id="container">
<div id="main1">
{% block body %}{% endblock %}
</div>
</div>
</body>
</html>
{% extends "base.html" %}
{% block title %}
DayZ Roleplaying Personality Generator
{% endblock title %}
{% block head %}
<style>
#header + #content > left > #rlblock_left {display:none !important;}
</style>
{% endblock head %}
{% block body %}
<div id='textbox'>
<table>
{% for cat, val in info.items() %}
<tr>
<td>{{ cat }}</td>
<td style='text-align: right'>{{ val }}</td>
</tr>
{% endfor %}
</table>
</div>
<h1>OR</h1>
<div id='textbox'><h4>You are a {{ dg_pair[0]|lower }}. {{ dg_pair[1] }}</h4></div>
<p>This character:
<a href='{{ url }}'>
<input type='text' style='width: 100%;' onClick='this.select()' value='{{ url }}' readonly>
</a>
<a href='{{ request.base_url }}'>
Generate Another
</a>
</p>
{% endblock body %}
from collections import OrderedDict
import random
from flask import Blueprint, render_template, request, json
drpg = Blueprint('drpg', __name__, url_prefix='/drpg')
char_stats = OrderedDict([
('Color', ['black', 'red', 'green', 'yellow', 'orange',
'pink', 'white', 'grey', 'blue']),
('Area', ['North', 'East', 'South', 'West', 'North West', 'Mid North',
'North East', 'South West', 'Mid South', 'South East']),
('Gear', ['military', 'survivalist', 'civilian']),
('Weapon', ['rifle', 'smg', 'handgun', 'shotgun',
'axe', 'knife', 'fists']),
('Nationality', ['Takistani', 'Kiwi', 'Russian', 'Northern Chernarussian',
'Southern Chernarussian']),
('Profession', ['tunnel snake', 'civilian', 'civilian', 'civilian',
'national soldier', 'UN soldier', 'rebel (Red Star)',
'farmer', 'fisherman', 'hunter', 'sidekick', 'gatherer',
'lumberjack', 'medic', 'thief', 'travelling merchant',
'cook', 'singer', 'jack of all trades', 'police',
'shopkeeper', 'car salesman', 'zombie sympathizer',
'Dexter', 'Jehovah\'s witness', 'tourist', 'slaver']),
('Phobia', ['nothing', 'combat', 'people', 'heights', 'guns', 'clothes']),
('Addiction', ['nothing', 'alcohol', 'caffeine', 'raw meat', 'painkillers',
'feet', 'stealing', 'hoarding']),
('Trust', ['distrusting', 'skeptical', 'wary', 'naive', 'gullible']),
('Strategy', ['brain', 'normal', 'normal', 'brawn']),
('Courage', ['courageous', 'normal', 'normal', 'cowardly']),
('Optimism', ['everything is terrible', 'pessimist', 'normal', 'normal',
'optimist', 'everything is awesome']),
('Paranoid', (['no'] * 5) + ['yes']),
('Psychopath', (['no'] * 10) + ['yes']),
('Cannibal', (['no'] * 20) + ['yes'])
])
# this was taken from a reddit post from 2015 (i think)
dice_game = {
'Hero': (
"You must take a town under your protection and keep it civil. You're the new sheriff in town.",
"You must find and use a revolver! You're not Rick Grimes, act accordingly. Also, try and find Carl.",
"You must find a group of hero players and survive with them.",
"You are Batman. Find all the bad guys and take care of them.",
"You must find, stalk, and kill psychopaths. Hurt nobody else. If threatened, run away.",
"You are a medic! Do your best to help wounded players, in your group or outside it. Use no weapons."),
'Good Guy': (
"You must spend your time finding food and giving it away.",
"You must do your best to light up a town at night time.",
"You must spend your time collecting and making bambi starter kits and handing them out at the beach.",
"You must find a bambi and help them find weapons, food, and drinks.",
"You must collect and give away backpacks to bambis at the coast.",
"You are Robin, go find Batman."),
'Survivor': (
"You must survive as long as possible by all means necessary.",
"You must select a town and make it a trading post. You may need a sheriff or other protection against bandits.",
"You must find a group and survive with them.",
"You must survive as long as possible with no weapon other than your trusty axe.",
"You must survive as long as possible without a backpack.",
"You must survive by being a bandit and robbing others. You can only take their belongings off their dead bodies."),
'Bad Guy': (
"You must find a group and befriend them. When you get the chance, knock one of them out and steal his gear.",
"You must find weapons and give them away to the least trustworthy people you can find.",
"You must start an underground fight club in a populated zone. Hire protection if necessary.",
"You must spend your time finding food and disposing of it so nobody will find it.",
"You must find and kill anyone using their mic to play music. If successful, you play music.",
"You must find a sniper rifle and hide near the coast scaring bambis by taking pot shots at them. Don't hit them."),
'Crazy Person': (
"You are a vegan. Use no animal products and tell everyone you meet about it.",
"You must survive by trading books for food and water.",
"You must find a bible and walk around spreading the word of God. Live off of donations of food and water.",
"You must survive only on Pipsi.",
"You must find the uglist clothes you can and survive by dancing in the street for food while blasting music over VOIP.",
"You must survive by only eating rotten food."),
'Psychopath': (
"You are an axe murderer. Slaughter as many people as you can with your axe.",
"You must befriend a stranger then kill them as they're doing something good for you or another person.",
"You are 360NoScope420-4Ever-Yolo. Find a sniper rifle and snipe bambis in a populated area.",
"You must find a pistol, revolver, or sawed-off and hide it. When you meet people, do the friendly dance then shoot them in the back when you get the chance.",
"You must kill as many people as possible but only by shooting them in the back.",
"You're the shotgun murderer. You must kill everyone you see using only a shotgun.")
}
@drpg.route('/')
@drpg.route('/api')
def drpg_page():
info = OrderedDict()
post_params = OrderedDict()
dg_pair = []
for category in char_stats.keys():
cat = category[:3].lower()
post_params[cat] = request.args.get(cat, default=None, type=int)
post_params['dgc'] = request.args.get('dgc', default=None, type=str)
post_params['dgv'] = request.args.get('dgv', default=None, type=int)
if any([value is None for value in post_params.values()]):
post_params = OrderedDict()
for cat, val in char_stats.items():
info[cat] = random.choice(val)
post_params[cat[:3].lower()] = val.index(info[cat])
dg_pair.append(random.choice(list(dice_game.keys())))
dg_pair.append(random.choice(dice_game[dg_pair[0]]))
post_params['dgc'] = dg_pair[0][:3].lower()
post_params['dgv'] = dice_game[dg_pair[0]].index(dg_pair[1])
else:
for param, val in post_params.items():
for cat, cval in char_stats.items():
if cat.startswith(param.title()):
info[cat] = cval[val]
break
for cat, action in dice_game.items():
if cat.startswith(post_params['dgc'].title()):
dg_pair.append(cat)
dg_pair.append(action[post_params['dgv']])
break
post_params = ['{}={}'.format(p, v) for p, v in post_params.items()]
url = '{}?{}'.format(request.base_url, '&'.join(post_params))
if request.path.endswith('api'):
return json.jsonify(**info, url=url.replace('/api', '/'), api_url=url, dg_pair=dg_pair)
else:
return render_template('drpg.html', info=info, url=url, dg_pair=dg_pair)
/* note i stole this off some other site because it looked decent, the site was something like blueblur.net */
body
{
background: #2D2D2D;
font-size: small;
color: white;
font-family: verdana, arial, helvetica, sans-serif;
margin: 0px 200px;
padding: 0px;
height: auto;
display: flex;
margin-bottom: 25px;
}
#container
{
width: 100%;
background-color: #2D2D2D;
padding: 0px;
margin: 0px;
height: 100%;
}
#header
{
background-color: transparent;
text-align: center;
padding: 10px;
}
#menubar
{
background-color: #2D2D2D;
padding: 5px;
border: 8px;
font-size: large;
font-weight: bold;
text-align: center;
color: white;
}
#menubartext
{
font-weight: bold;
padding: 5px;
margin: 0px;
}
#main1
{
padding: 25px;
border-radius: 10px;
background: #565656;
}
#textbox{
background: #2D2D2D;
border-radius: 10px;
margin: 10px;
padding: 10px;
height: 60%;
}
#menubarlink{
text-decoration: none;
color: #EEEEEE;
text-decoration: underline;
}
h2{
margin-top: 0px;
display: inline;
}
table{
width: 100%;
}
a{
color: #D64937;
}
th, td {
width: 20%;
padding: 5px;
text-align: left;
font-weight: bold;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment