-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarching
executable file
·155 lines (149 loc) · 3.64 KB
/
marching
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
#!/usr/bin/python
from __future__ import print_function
import afal_config
import afal
import cgi
import cgitb
import os
import sys
import string
cgitb.enable()
form = cgi.FieldStorage()
todo = form.getfirst('todo')
if todo is None or todo == '' or '.' not in todo:
os.execv('./menu', sys.argv)
(cl, inst) = todo.split('.', 1)
if cl != 'marching':
os.execv('./menu', sys.argv)
marching = inst
list = afal.get_marching(marching)
title = 'Marching order for {marching}'.format(marching = marching)
style = """ <style type="text/css">
.marching {{
text-align: center;
}}
.marching th,.marching td,.marching div {{
width: 20px;
height: 20px;
}}
.w3h3 {{
width: 60px;
height: 60px;
}}
.w3h6 {{
width: 60px;
height: 120px;
}}
.w8h13 {{
width: 160px;
height: 260px;
}}
.w4h8 {{
width: 80px;
height: 160px;
}}
.w8h10 {{
width: 160px;
height: 200px;
}}
.human {{
background:black;
color: yellow;
text-align: center;
overflow: hidden;
}}
.dwarf {{
background:green;
color: yellow;
text-align: center;
overflow: hidden;
}}
.halfelf {{
background:#0000a0;
color: yellow;
text-align: center;
overflow: hidden;
}}
.halforc {{
background:#a00000;
color: yellow;
}}
.elf {{
background:blue;
color: yellow;
text-align: center;
overflow: hidden;
}}
.orc {{
background:red;
color: yellow;
}}
.other {{
background: yellow;
color: black;
text-align: center;
overflow: hidden;
}}
</style>
"""
rows = 0
cols = 0
for i in list:
o = i['over'] + i['width']
d = i['down'] + i['height']
if o > cols:
cols = o
if d > rows:
rows = d
colhdr = ''
for i in range(1,cols+1):
colhdr += '<th>{i}'.format(i = i)
print('''{hdr}
<h1>{marching}</h1>
<table class="marching">
<col width="0.5*"><col span="{cols}" width="20">
<thead>
<tr><td>{colhdr}
<tbody>'''.format(hdr = afal.html_header(title, style), marching = marching, cols = cols, colhdr = colhdr))
for r in range(1, rows+1):
s = ' <tr><th>{r}'.format(r = r)
c = 1
while len(list) > 0 and list[0]['down'] == r:
p = list[0]
o = p['over']
if o == c:
pass
elif o == c + 1:
s += '<td>'
c += 1
else:
n = o - c
s += '<td colspan ="{n}">'.format(n = n)
c += n
cl = p['race']
if cl is None:
cl = 'other'
elif 'Human' in cl:
cl = 'human'
elif 'Dwarf' in cl:
cl = 'dwarf'
elif '½' in cl:
if 'Elf' in cl:
cl = 'halfelf'
elif 'Orc' in cl:
cl = 'halforc'
else:
cl = 'halfhuman'
elif 'Elf' in cl:
cl = 'elf'
elif 'Orc' in cl:
cl = 'orc'
else:
cl = 'other'
wh = 'w{w}h{h}'.format(w = p['width'], h = p['height'])
title = string.join(filter(None, [p['race'], p['gender'], p['class'], p['hidden_note']]), ' ')
s += '<td rowspan="{h}" colspan="{w}" class="{cl} {wh}" title="{t}"><div>{ch}</div>'.format(w = p['width'], h = p['height'], ch = p['char'], cl = cl, t = title, wh = wh)
c += p['width']
list = list[1:]
print(s)
print(' </table>\n' + afal.html_footer())