add enumeration of bots

This commit is contained in:
Chris Forbes
2010-12-21 18:13:38 +13:00
parent 7ef884532d
commit 29fbeb2c5d
4 changed files with 16 additions and 5 deletions

View File

@@ -33,8 +33,18 @@ using XRandom = OpenRA.Thirdparty.Random;
namespace OpenRA.Mods.RA
{
class HackyAIInfo : ITraitInfo
interface IBotInfo
{
string Name { get; }
}
class HackyAIInfo : IBotInfo, ITraitInfo
{
[FieldLoader.Load]
public readonly string Name;
string IBotInfo.Name { get { return this.Name; } }
[FieldLoader.LoadUsing("LoadUnits")]
public readonly Dictionary<string, float> UnitsToBuild = null;

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Mods.RA.Server
{
var parts = s.Split(' ');
if (parts.Length != 2)
if (parts.Length < 2)
{
server.SendChatTo( conn, "Malformed slot_bot command" );
return true;
@@ -181,7 +181,7 @@ namespace OpenRA.Mods.RA.Server
return true;
}
slotData.Bot = parts[1];
slotData.Bot = string.Join(" ", parts.Skip(1).ToArray() );
server.SyncLobbyInfo();
return true;

View File

@@ -211,7 +211,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
if (showBotOptions)
{
var bots = new string[] { "HackyAI" };
var bots = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
bots.Do(bot =>
dropDownOptions.Add(new Pair<string, Action>("Bot: {0}".F(bot),
() => orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot.Index, bot))))));

View File

@@ -32,7 +32,8 @@ Player:
InitialCash: 5000
ActorGroupProxy:
DeveloperMode:
HackyAI:
HackyAI@Default:
Name:Easy AI
BuildingFractions:
proc: 20%
barr: 5%