ported from perforce
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public sealed record BufferOverflowRequest(Guid RequestId) : Request(RequestId)
|
||||
{
|
||||
public static BufferOverflowRequest Create(CoreLoop coreLoop)
|
||||
{
|
||||
coreLoop.ShuffleDeck();
|
||||
coreLoop.DrawHand();
|
||||
return new(Guid.NewGuid());
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Buffer overflow request";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using RobotAndDonkey.Game.Cards;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public sealed record DrawGlitchRequest(Guid RequestId, Card Card) : Request(RequestId)
|
||||
{
|
||||
public static DrawGlitchRequest Create(CoreLoop coreLoop)
|
||||
{
|
||||
return new(Guid.NewGuid(), coreLoop.GlitchDeck[coreLoop.NextGlitch]);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Draw glitch request: {Card}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using RobotAndDonkey.Game.Execution.Commands;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public sealed record ExecuteProgramRequest(Guid RequestId) : Request(RequestId)
|
||||
{
|
||||
public static ExecuteProgramRequest Create(CoreLoop coreLoop)
|
||||
{
|
||||
return new(Guid.NewGuid());
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Execute program request";
|
||||
}
|
||||
}
|
||||
20
RobotAndDonkey.Game/Execution/Requests/GambleRequest.cs
Normal file
20
RobotAndDonkey.Game/Execution/Requests/GambleRequest.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using RobotAndDonkey.Game.Cards;
|
||||
using RobotAndDonkey.Game.Data;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public sealed record GambleRequest(Guid RequestId) : Request(RequestId)
|
||||
{
|
||||
public static GambleRequest Create(CoreLoop coreLoop)
|
||||
{
|
||||
return new(Guid.NewGuid());
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Gamble request";
|
||||
}
|
||||
}
|
||||
18
RobotAndDonkey.Game/Execution/Requests/ImproveRequest.cs
Normal file
18
RobotAndDonkey.Game/Execution/Requests/ImproveRequest.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using RobotAndDonkey.Game.Execution.Commands;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public sealed record ImproveRequest(Guid RequestId) : Request(RequestId)
|
||||
{
|
||||
public static ImproveRequest Create(CoreLoop coreLoop)
|
||||
{
|
||||
return new(Guid.NewGuid());
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Improve request";
|
||||
}
|
||||
}
|
||||
22
RobotAndDonkey.Game/Execution/Requests/Request.cs
Normal file
22
RobotAndDonkey.Game/Execution/Requests/Request.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using RobotAndDonkey.Game.Execution.Commands;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public abstract record Request(Guid RequestId)
|
||||
{
|
||||
public bool IsCommandCompatible(Command command)
|
||||
{
|
||||
foreach (var requestType in command.RequestTypes)
|
||||
{
|
||||
if (requestType == GetType())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static readonly EmptyRequest s_Empty = new();
|
||||
}
|
||||
|
||||
public sealed record EmptyRequest() : Request(Guid.Empty);
|
||||
18
RobotAndDonkey.Game/Execution/Requests/ScoringRequest.cs
Normal file
18
RobotAndDonkey.Game/Execution/Requests/ScoringRequest.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using RobotAndDonkey.Game.Execution.Commands;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Requests;
|
||||
|
||||
public sealed record ScoringRequest(Guid RequestId) : Request(RequestId)
|
||||
{
|
||||
public static ScoringRequest Create(CoreLoop coreLoop)
|
||||
{
|
||||
return new(Guid.NewGuid());
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Scoring request";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user