- Making the new highlight/select bindings work

- script to move selected regions
This commit is contained in:
Enno Rehling 2006-05-25 22:34:58 +00:00
parent 964387c834
commit 6b835e9b82
4 changed files with 41 additions and 9 deletions

View File

@ -523,17 +523,16 @@ max_magicians(const faction * f)
int
max_skill(faction * f, skill_t sk)
{
int m = INT_MAX;
if (allied_skilllimit(f, sk)) {
int m = INT_MAX;
int al = allied_skilllimit(f, sk);
if (al>0) {
if (sk!=SK_ALCHEMY && sk!=SK_MAGIC) return INT_MAX;
if (f->alliance!=NULL) {
int ac = listlen(f->alliance->members); /* number of factions */
int al = allied_skilllimit(f, sk); /* limit per alliance */
int fl = (al+ac-1)/ac; /* faction limit */
/* the following ist _very_ weird, please examine */
int fl = (al+ac-1)/ac; /* faction limit, rounded up */
/* the faction limit may not be achievable because it would break the alliance-limit */
int sc = al - allied_skillcount(f, sk);
if (sc==0) return count_skill(f, sk);
if (sc<=0) return 0;
return fl;
}
}

View File

@ -243,7 +243,7 @@ init_curses(void)
if (has_colors() || force_color) {
short bcol = COLOR_BLACK;
short hcol = COLOR_CYAN;
short hcol = COLOR_MAGENTA;
start_color();
#ifdef WIN32
/* looks crap on putty with TERM=linux */
@ -698,7 +698,7 @@ highlight_region(region *r)
}
void
select_coordinate(selection * selected, int x, int y)
select_coordinate(struct selection * selected, int x, int y)
{
coordinate coord = { 0 };
coord.x = x;

View File

@ -15,6 +15,7 @@
extern "C" {
#endif
struct lua_State;
struct selection;
extern int gmmain(int argc, char *argv[]);
extern int curses_readline(struct lua_State * L, const char * prompt);

32
src/scripts/gm/move.lua Normal file
View File

@ -0,0 +1,32 @@
swapx = 0
swapy = 0
function swap_region(r, tr)
local sr = get_region(swapx, swapy)
while sr~=nil do
swapx = math.random(1000)
swapy = math.random(1000)
sr = get_region(swapx, swapy)
end
local tx = tr.x
local ty = tr.y
local x = r.x
local y = r.y
tr:move(swapx, swapy)
r:move(tx, ty)
tr:move(x, y)
end
function move_selection(x, y)
for r in gmtool.selection() do
local tx = r.x+x
local ty = r.y+y
local tr = get_region(tx, ty)
if tr~=nil then
swap_region(r, tr)
else
r:move(tx, ty)
end
end
end