forked from github/server
- Spezialeigenschaften verbessert.
- Prototyp für einen Algorithmus zur Ermittlung von Schlachten und Angriffen bei Einführung von VORRÜCKEN, in python.
This commit is contained in:
parent
435e98f50c
commit
7d70ca82b5
|
@ -437,7 +437,7 @@ cr_output_unit(FILE * F, region * r,
|
|||
}
|
||||
|
||||
if(u->faction != f && a_fshidden
|
||||
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 5) {
|
||||
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
||||
fprintf(F, "-1;Anzahl\n");
|
||||
} else {
|
||||
fprintf(F, "%d;Anzahl\n", u->number);
|
||||
|
@ -546,7 +546,7 @@ cr_output_unit(FILE * F, region * r,
|
|||
if (f == u->faction || u->faction->race==RC_ILLUSION) {
|
||||
show = u->items;
|
||||
} else if (itemcloak==false && mode>=see_unit && !(a_fshidden
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 2)) {
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) {
|
||||
show = NULL;
|
||||
for (itm=u->items;itm;itm=itm->next) {
|
||||
item * ishow;
|
||||
|
|
|
@ -2565,7 +2565,7 @@ ageing(void)
|
|||
static int
|
||||
maxunits(faction *f)
|
||||
{
|
||||
return MAXUNITS + 250 * fspecial(f, FS_ADMINISTRATOR);
|
||||
return MAXUNITS + 400 * fspecial(f, FS_ADMINISTRATOR);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: karma.c,v 1.3 2001/02/28 18:25:25 corwin Exp $
|
||||
* $Id: karma.c,v 1.4 2001/03/07 15:00:18 corwin Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -88,7 +88,7 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
|
|||
false
|
||||
},
|
||||
{
|
||||
"Krieger",
|
||||
"Barbar",
|
||||
"Einheiten dieser Partei erhalten durch Lernen von Waffentalenten "
|
||||
"(Taktik und Reiten zählen nicht dazu!) 40 statt 30 Lerntage. Weitere "
|
||||
"Stufen erhöhen den Bonus um +5/+10. Die Fokussierung auf das "
|
||||
|
@ -133,9 +133,9 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
|
|||
{
|
||||
"Administrator",
|
||||
"Das Einheitenlimit einer Partei mit dieser Eigenschaft erhöht sich um "
|
||||
"250 Einheiten. Leider verschlingt der Verwaltungsaufwand viel Silber, "
|
||||
"400 Einheiten. Leider verschlingt der Verwaltungsaufwand viel Silber, "
|
||||
"so dass sich der Unterhalt pro Person um 1 Silberstück erhöht. Weitere "
|
||||
"Stufen der Eigenschaft erhöhen das Limit um weitere 250 Einheiten und "
|
||||
"Stufen der Eigenschaft erhöhen das Limit um weitere 400 Einheiten und "
|
||||
"den Unterhalt um ein weiteres Silberstück.",
|
||||
true
|
||||
},
|
||||
|
@ -190,9 +190,9 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
|
|||
{
|
||||
"Versteckt",
|
||||
"Eine Partei mit dieser Eigenschaft hat die Fähigkeit zu Tarnung "
|
||||
"zur Perfektion getrieben. Jede Einheit mit mindestens Tarnung 2 "
|
||||
"zur Perfektion getrieben. Jede Einheit mit mindestens Tarnung 3 "
|
||||
"versteckt alle ihre Gegenstände so, daß sie von anderen Parteien "
|
||||
"nicht mehr gesehen werden können. Jede Einheit mit mindestens Tarnung 5 "
|
||||
"nicht mehr gesehen werden können. Jede Einheit mit mindestens Tarnung 6 "
|
||||
"schafft es auch, die Zahl der in ihr befindlichen Personen zu verbergen. "
|
||||
"Um diese Eigenschaft steuern zu können, stehen diesen Parteien die "
|
||||
"Befehle TARNE ANZAHL [NICHT] und TARNE GEGENSTÄNDE [NICHT] zur "
|
||||
|
@ -208,7 +208,6 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
|
|||
"Woche ihren normalen Tätigkeiten nachzugehen.",
|
||||
false
|
||||
},
|
||||
/* TODO: Noch nicht implementiert */
|
||||
{
|
||||
"Magische Immunität",
|
||||
"Eine Partei mit dieser Eigenschaft ist völlig immun gegen alle Arten "
|
||||
|
@ -224,7 +223,6 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
|
|||
"jeweils einem weiteren Magier das Lernen eines anderen Gebiets.",
|
||||
true
|
||||
},
|
||||
/* TODO: Namen ändern, negative Eigenschaft implementieren */
|
||||
{
|
||||
"Jihad",
|
||||
"Eine Partei mit dieser Eigenschaft kann eine (Spieler)-Rasse "
|
||||
|
@ -554,3 +552,4 @@ jihad_attacks(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: magic.c,v 1.11 2001/02/18 10:06:09 enno Exp $
|
||||
* $Id: magic.c,v 1.12 2001/03/07 15:00:18 corwin Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -1213,6 +1213,8 @@ target_resists_magic(unit *magician, void *obj, int objtyp, int t_bonus)
|
|||
int at, pa = 0;
|
||||
skill_t i;
|
||||
|
||||
if(fspecial(((unit *)obj)->faction, FS_MAGICIMMUNE)) return true;
|
||||
|
||||
at = effskill(magician, SK_MAGIC);
|
||||
|
||||
for (i=0;i<MAXSKILLS;i++) {
|
||||
|
@ -1445,6 +1447,8 @@ regeneration(unit * u)
|
|||
double potenz = 1.5;
|
||||
double divisor = 2.0;
|
||||
|
||||
if(fspecial(u->faction, FS_MAGICIMMUNE)) return 0;
|
||||
|
||||
sk = effskill(u, SK_MAGIC);
|
||||
/* Rassenbonus/-malus */
|
||||
d = (int)(pow(sk, potenz) * race[u->race].regaura / divisor);
|
||||
|
@ -1503,7 +1507,7 @@ regeneration_magiepunkte(void)
|
|||
}
|
||||
set_spellpoints(u, min(aura, auramax));
|
||||
|
||||
/* Zum letzten Mal Spruchliste aktualiesieren */
|
||||
/* Zum letzten Mal Spruchliste aktualisieren */
|
||||
updatespelllist(u);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
*
|
||||
* $Id: reports.c,v 1.7 2001/02/28 23:28:54 enno Exp $
|
||||
* $Id: reports.c,v 1.8 2001/03/07 15:00:18 corwin Exp $
|
||||
* Eressea PB(E)M host Copyright (C) 1998-2000
|
||||
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
||||
* Katja Zedel (katze@felidae.kn-bremen.de)
|
||||
|
@ -207,7 +207,7 @@ bufunit(const faction * f, const unit * u, int indent,
|
|||
}
|
||||
scat(", ");
|
||||
if(u->faction != f && a_fshidden
|
||||
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 5) {
|
||||
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
||||
scat("? ");
|
||||
} else {
|
||||
icat(u->number);
|
||||
|
@ -270,7 +270,7 @@ bufunit(const faction * f, const unit * u, int indent,
|
|||
if (f == u->faction || telepath_see || u->faction->race==RC_ILLUSION) {
|
||||
show = u->items;
|
||||
} else if (!itemcloak && mode >= see_unit && !(a_fshidden
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 2)) {
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) {
|
||||
show = NULL;
|
||||
for (itm=u->items;itm;itm=itm->next) {
|
||||
item * ishow;
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from Stack import *
|
||||
|
||||
class Node:
|
||||
def __init__(self, obj):
|
||||
self.obj = obj
|
||||
self.marker = 0
|
||||
|
||||
class Vertex:
|
||||
def __init__(self, node1, node2):
|
||||
self.nodes = (node1, node2)
|
||||
self.marker = 0
|
||||
|
||||
class Graph:
|
||||
|
||||
def __init__(self):
|
||||
self.nodes = []
|
||||
self.vertices = []
|
||||
|
||||
def remove_node(self, node):
|
||||
self.nodes.remove(node)
|
||||
for v in self.vertices:
|
||||
if v.nodes[0] == node or v.nodes[1] == node:
|
||||
self.vertices.remove(v)
|
||||
|
||||
def find_node(self, obj):
|
||||
for n in self.nodes:
|
||||
if n.obj == obj:
|
||||
return n
|
||||
|
||||
return None
|
||||
|
||||
def neighbours(self, node):
|
||||
n = []
|
||||
for v in self.vertices:
|
||||
if v.nodes[0] == node and v.nodes[1] not in n:
|
||||
n.append(v.nodes[1])
|
||||
elif v.nodes[1] == node and v.nodes[0] not in n:
|
||||
n.append(v.nodes[0])
|
||||
|
||||
return n
|
||||
|
||||
def reset_marker(self):
|
||||
for n in self.nodes:
|
||||
n.marker = 0
|
||||
for v in self.vertices:
|
||||
v.marker = 0
|
||||
|
||||
def dsearch(self,node):
|
||||
reset_marker()
|
||||
dg = [node]
|
||||
s = Stack()
|
||||
node.marker = 1
|
||||
s.push(node)
|
||||
while not s.empty():
|
||||
n = s.pop()
|
||||
for nb in self.neighbours(n):
|
||||
if nb.marker == 0:
|
||||
nb.marker = 1
|
||||
dg.append(nb)
|
||||
s.push(nb)
|
||||
return dg
|
||||
|
||||
def dgraphs(self):
|
||||
rl = []
|
||||
nodelist = self.nodes[:]
|
||||
while nodelist != []:
|
||||
start = nodelist.pop()
|
||||
self.reset_marker()
|
||||
g = Graph()
|
||||
g.nodes.append(start)
|
||||
start.marker = 1
|
||||
s = Stack()
|
||||
s.push(start)
|
||||
while not s.empty():
|
||||
tnode = s.pop()
|
||||
for nb in self.neighbours(tnode):
|
||||
if nb.marker == 0:
|
||||
nb.marker = 1
|
||||
g.nodes.append(nb)
|
||||
nodelist.remove(nb)
|
||||
s.push(nb)
|
||||
|
||||
for v in self.vertices:
|
||||
if v.nodes[0] in g.nodes:
|
||||
g.vertices.append(v)
|
||||
|
||||
rl.append(g)
|
||||
|
||||
return rl
|
||||
|
||||
# g = Graph()
|
||||
|
||||
# n1 = Node(1)
|
||||
# n2 = Node(2)
|
||||
# n3 = Node(3)
|
||||
# n4 = Node(4)
|
||||
# n5 = Node(5)
|
||||
# n6 = Node(6)
|
||||
|
||||
# g.nodes.append(n1)
|
||||
# g.nodes.append(n2)
|
||||
# g.nodes.append(n3)
|
||||
# g.nodes.append(n4)
|
||||
# g.nodes.append(n5)
|
||||
# g.nodes.append(n6)
|
||||
|
||||
# g.vertices.append(Vertex(n1,n2))
|
||||
# g.vertices.append(Vertex(n1,n4))
|
||||
# g.vertices.append(Vertex(n2,n6))
|
||||
|
||||
# for dg in g.dgraphs():
|
||||
# for e in dg:
|
||||
# print e.obj,
|
||||
# print
|
||||
|
||||
|
||||
|
Binary file not shown.
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
class Stack:
|
||||
def __init__(self):
|
||||
self.data = []
|
||||
|
||||
def push(self, obj):
|
||||
self.data.append(obj)
|
||||
|
||||
def pop(self):
|
||||
return self.data.pop()
|
||||
|
||||
def empty(self):
|
||||
if self.data == []:
|
||||
return 1
|
||||
return 0
|
||||
|
Binary file not shown.
|
@ -0,0 +1,148 @@
|
|||
#!/usr/bin/python
|
||||
# vi:set ts=4:
|
||||
|
||||
# Algorithmus zur Berechnung von regionsübergreifenden Schlachten.
|
||||
# Testprogramm.
|
||||
|
||||
# 1) Graph aufbauen aus alle Attackierern und allen direkt attackierten
|
||||
|
||||
# 2) Helfer in den Graphen aufnehmen
|
||||
|
||||
# 3) Disjunkte Teilgraphen ermitteln
|
||||
|
||||
# 4) Innerhalb der Teilgraphen die 'Wer-schlägt-wen-Beziehung' aufbauen
|
||||
|
||||
import re
|
||||
from Stack import *
|
||||
from Graph import *
|
||||
|
||||
class heer:
|
||||
def __init__(self, rx, ry, f, o):
|
||||
self.rx = rx
|
||||
self.ry = ry
|
||||
self.f = f
|
||||
self.o = o
|
||||
self.attacked = []
|
||||
|
||||
def toString(self):
|
||||
return "("+self.f+","+str(self.rx)+","+str(self.ry)+")"
|
||||
|
||||
|
||||
def dist(x1, y1, x2, y2):
|
||||
dx = x1 - x2
|
||||
dy = y1 - y2
|
||||
if dy < 0:
|
||||
dy = -dy
|
||||
dx = -dx
|
||||
if dx >= 0:
|
||||
return dx + dy;
|
||||
if -dx >= dy:
|
||||
return -dx
|
||||
return dy
|
||||
|
||||
|
||||
def is_neighbour(h, r1, r2):
|
||||
x1 = r1[0]
|
||||
y1 = r1[1]
|
||||
x2 = r2[0]
|
||||
y2 = r2[1]
|
||||
|
||||
if dist(h.rx, h.ry, x1, y1) <= 1 and dist(h.rx, h.ry, x2, y2) <= 1:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
heere = [
|
||||
Node(heer(0,-2, 'D', 'A->C:1,-3')),
|
||||
Node(heer(1,-3, 'D', '')),
|
||||
Node(heer(1,-2, 'D', '')),
|
||||
Node(heer(2,-3, 'D', 'A->C:1,-3')),
|
||||
Node(heer(1,-2, 'C', 'L->D')),
|
||||
Node(heer(1,-3, 'C', 'A->D:1,-2')),
|
||||
Node(heer(0, 0, 'A', '')),
|
||||
Node(heer(0, 0, 'B', 'L->A'))
|
||||
]
|
||||
|
||||
def find_heer_node(x, y, f):
|
||||
for node in heere:
|
||||
h = node.obj
|
||||
if h.rx == x and h.ry == y and h.f == f:
|
||||
return node
|
||||
return None
|
||||
|
||||
def allied(f1, f2):
|
||||
if f1 == f2:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
g1 = Graph()
|
||||
|
||||
a_re = re.compile('A->(\w):(-?\d+),(-?\d+)')
|
||||
l_re = re.compile('L->(\w)')
|
||||
|
||||
# Schritt 1
|
||||
|
||||
for node in heere:
|
||||
f = ''
|
||||
h = node.obj
|
||||
|
||||
mo = a_re.match(h.o)
|
||||
if mo != None:
|
||||
f = mo.group(1)
|
||||
x = int(mo.group(2))
|
||||
y = int(mo.group(3))
|
||||
|
||||
mo = l_re.match(h.o)
|
||||
if mo != None:
|
||||
f = mo.group(1)
|
||||
x = h.rx
|
||||
y = h.ry
|
||||
|
||||
if f != '':
|
||||
tnode = find_heer_node(x,y,f)
|
||||
if node not in g1.nodes:
|
||||
g1.nodes.append(node)
|
||||
if tnode not in g1.nodes:
|
||||
g1.nodes.append(tnode)
|
||||
g1.vertices.append(Vertex(node,tnode))
|
||||
tnode.obj.attacked.append((x,y,node))
|
||||
|
||||
# Schritt 2
|
||||
|
||||
for node1 in g1.nodes:
|
||||
heer1 = node1.obj
|
||||
for attack in heer1.attacked:
|
||||
attacker_node = attack[2]
|
||||
for node2 in heere:
|
||||
heer2 = node2.obj
|
||||
# heer 1 ist der angegriffene
|
||||
# heer 2 der potentielle Helfer
|
||||
if heer1 != heer2 and allied(heer1.f,heer2.f) and not allied(heer2.f, attacker_node.obj.f):
|
||||
if is_neighbour(heer2, (heer1.rx, heer1.ry), attack):
|
||||
if node2 not in g1.nodes:
|
||||
g1.nodes.append(node2)
|
||||
g1.vertices.append(Vertex(attacker_node,node2))
|
||||
|
||||
# Schritt 3
|
||||
|
||||
battles = g1.dgraphs()
|
||||
|
||||
count = 1
|
||||
|
||||
for battle in battles:
|
||||
print "Schlacht "+str(count),
|
||||
count = count + 1
|
||||
for node in battle.nodes:
|
||||
heer = node.obj
|
||||
print heer.toString()+",",
|
||||
print
|
||||
|
||||
# Schritt 4
|
||||
|
||||
for node in battle.nodes:
|
||||
heer = node.obj
|
||||
print "\tHeer "+str(heer.toString())+" attackiert gegen",
|
||||
for enemy in battle.neighbours(node):
|
||||
print str(enemy.obj.toString())+",",
|
||||
print
|
||||
|
Loading…
Reference in New Issue