Deleted member 219079
D
Deleted member 219079
My system outprints like this:
My code is in 3 triggers, but here's the one which does the stuff:
And then here's the other one which might cause errors:
Here's the map:
My code is in 3 triggers, but here's the one which does the stuff:
JASS:
scope TBMS /*Turn Based Movement System v1.0.0*/ initializer init //Requires PlayerEx, PlayerColor
//===========================================================================
globals
//Constants
private constant force FORCE = CreateForce()
private constant timer TIMER = CreateTimer()
private PlayerList Players
//System configuration
private constant integer DUMMY_ID = 'h000'
//Presentation configuration
private constant real INTERVAL = 5.
private constant string TEXT_COL = "|c006699ff"
private constant string DIGIT_COL = "|c00ffcc66"
private constant real MSG_DURATION = 5.
endglobals
//===========================================================================
private function PlayerFilter takes nothing returns boolean
return GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
endfunction
//===========================================================================
private function TimeOut takes nothing returns nothing
call Players.RemovePlayer(Player(2))
call Players.RemovePlayer(Players.GetCurrentPlayer())
call Players.PrintOrderForPlayer(GetLocalPlayer(),MSG_DURATION)
endfunction
//===========================================================================
private function init takes nothing returns nothing
set Players = PlayerList.create(Condition(function PlayerFilter))
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, /*
*/TEXT_COL+"Player list:\n\n")
call Players.PrintOrderForPlayer(GetLocalPlayer(),MSG_DURATION)
call TimerStart(TIMER, INTERVAL, true, function TimeOut)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, /*
*/TEXT_COL+"\nGame starting in "+DIGIT_COL+I2S(R2I(INTERVAL))+TEXT_COL+" seconds, hold on...|r")
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, /*
*/TEXT_COL+"Next turn: "+GetPlayerNameColored(Players.Next())+"|r")
endfunction
//===========================================================================
endscope
JASS:
library ForceEx requires PlayerColor /*
Player list library ;
Methods:
method RemovePlayer takes player pl returns nothing
- remove a player from your list
method PrintOrderForPlayer takes player pl, real d returns nothing
- prints the player list for specific player
method Next takes nothing returns player
- sets the next player on the list, and returns it
method GetNext takes nothing returns player
- returns the next player on the list
method GetCurrentPlayer takes nothing returns player
- returns the current player
*/
constant function GetBigger takes real r1, real r2 returns real
if r1 > r2 then
return r1
endif
return r2
endfunction
constant function GetBiggerInt takes integer r1, integer r2 returns integer
if r1 > r2 then
return r1
endif
return r2
endfunction
//===========================================================================
struct IndexPlayer extends array
player pl
static method flush takes integer index, integer end returns nothing
local integer i = index
loop
exitwhen i == end
set thistype[i].pl = thistype[i+1].pl
endloop
endmethod
endstruct
//===========================================================================
struct PlayerList
private integer first
private integer last
private integer index
private static integer tempInt = - 1 //represents the highest player index used
//===========================================================================
method RemovePlayer takes player pl returns nothing
local integer i = first
if i > last then //if first > last, a.k.a. the list is empty
debug call BJDebugMsg("|c00ff0000ForceEx ERROR: Function call for an empty player list!|r")
return
endif
loop
if IndexPlayer[i].pl == pl then
call IndexPlayer.flush(i,last)
set last = last - 1
return
endif
exitwhen i == last
set i = i + 1
endloop
debug call BJDebugMsg("|c00ff0000ForceEx ERROR: Unlisted player index used!|r")
endmethod
//===========================================================================
method PrintOrderForPlayer takes player pl, real d returns nothing
local integer i = first
if i > last then //if first > last, a.k.a. the list is empty
debug call BJDebugMsg("|c00ff0000ForceEx ERROR: Function call for an empty player list!|r")
return
endif
loop
call DisplayTimedTextToPlayer(pl, 0, 0, d, I2S(i+1)+". "+GetPlayerNameColored(IndexPlayer[i].pl))
exitwhen i == last
set i = i + 1
endloop
endmethod
//===========================================================================
method Next takes nothing returns player
set index = index + 1
if index>last then
set index = first
endif
return IndexPlayer[index].pl
endmethod
method GetNext takes nothing returns player
local integer i = index+1
if i>last then
set i=first
endif
return IndexPlayer[i].pl
endmethod
method GetCurrentPlayer takes nothing returns player
return IndexPlayer[index].pl
endmethod
//===========================================================================
static method initPlayerList takes nothing returns nothing
set tempInt = tempInt + 1
set IndexPlayer[tempInt].pl = GetEnumPlayer()
endmethod
static method create takes boolexpr be returns thistype
local thistype tbr = thistype.allocate()
local force f = CreateForce()
call ForceEnumPlayers(f, be)
set tbr.first = tempInt+1
set tbr.index = tempInt
call ForForce(f, function thistype.initPlayerList)
set tbr.last = tempInt
call DestroyForce(f)
set f = null
return tbr
endmethod
//===========================================================================
endstruct
endlibrary
Here's the map: