Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted by Emkas ( 16 years ago )
procedure drawBoard(gameBoard: boardElements);
    
        function turnKindOfField(i: Integer): char;
        begin
            if i = 1 then turnKindOfField:='.'
            else if i = 2 then turnKindOfField:='='
            else turnKindOfField:='^';
        end;
    
    var
    x: Integer;
    y: Integer;
   firstArmy: army;
    secondArmy: army;
    isInArmy:boolean;
 begin
        new(firstArmy);
  new(secondArmy);
        firstArmy:=gameBoard^.firstArmies;
        secondArmy:=gameBoard^.secondArmies;
     writeln('=');
     for y := 1 to gameBoard^.boardHeight do
        begin
         for x := 1 to gameBoard^.boardWidth do
   begin
       isInArmy:=false;
       if firstArmy<>nil then 
           if (firstArmy^.pos^.pos^.x=x) and (firstArmy^.pos^.pos^.y=y) then
                    begin
                        isInArmy:=true;
                        write(chr(firstArmy^.kind+96));
                        write(turnKindOfField(firstArmy^.pos^.kind));
                        write(firstArmy^.health);
                        firstArmy:=firstArmy^.nextArmy;    
                    end;
                if (not isInArmy) then begin
                    if secondArmy<>nil then                                    
                        if (secondArmy^.pos^.pos^.x=x) and (secondArmy^.pos^.pos^.y=y) then
                        begin
                            isInArmy:=true;
                            write(chr(secondArmy^.kind+64));
                            write(turnKindOfField(secondArmy^.pos^.kind));
                            write(secondArmy^.health);
                            secondArmy:=secondArmy^.nextArmy;
                        end
                end;
                if (not isInArmy) then
              write('.',turnKindOfField(gameBoard^.terrain[x,y]^.kind),'.');
                if x<>gameBoard^.boardWidth then write(' ');
   end;
   writeln();
  end;
  dispose(firstArmy);
  dispose(secondArmy);
     writeln();
 end;

 

Revise this Paste

Your Name: Code Language: