text
stringlengths
0
234
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
procedure Start_Game(Socket: in Socket_Type; Player: out Positive; Prot1, Prot2: out Protocoll_Type) is
TX : String(1..100);
TL : Natural;
begin -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
for I in 1..15 loop
Prot1(I) := -1;
end loop;
Prot2 := Prot1;
Get_Line(Socket, TX, TL);
if TX(1) = '1' then
message(33, 18, "Du är spelare 1, väntar på spelare 2");
Player := 1;
Get_Line(Socket, TX, TL);
New_Line;
if TX(1) = '3' then
message(33, 18, "Båda spelare anslutna");
end if;
elsif TX(1) = '2' then
message(33, 18, "Du är spelare 2");
Player := 2;
else
raise DATATYPE_ERROR;
end if;
New_Line;
message(33, 18, "Nu startar spelet");
New_Line;
end Start_Game;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function Read(C: in Character)
return Natural is
S: String(1..1);
begin
S(1) := C;
return Integer'Value(S);
end Read;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
procedure Get_Rolls(Socket: in Socket_Type; Roll: out Rolls_Type) is
TX: String(1..100);
TL: Natural;
begin
Get_Line(Socket, TX, TL);
New_Line;
if TX(1) = '4' then -- 4 betyder inkomande tärningar
Roll.I := Read(TX(2));
for X in 1..Roll.I loop -- A betyder här antalet tärningar
Roll.Rolls(X) := Read(TX(X+2));
end loop;
elsif TX(1) = '5' then -- 5 betyder info om gamestate
if TX(2) = '0' then -- Annan spelare slår
Roll.I := 6;
elsif TX(2) = '1' then -- Annan spelare har slagit
Roll.I := 7;
for X in 1..5 loop
Roll.Rolls(X) := Read(TX(X+2));
end loop;
elsif TX(2) = '2' then -- Annan spelare vill placera
Roll.I := 8;
for X in 1..5 loop
Roll.Rolls(X) := Read(TX(X+2));
end loop;
end if;
else
raise DATATYPE_ERROR;
end if;
end Get_Rolls;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --