Skip to content

Commit

Permalink
Merge pull request #2 from teshiba/develop
Browse files Browse the repository at this point in the history
for release v0.1.2
  • Loading branch information
teshiba authored Mar 26, 2020
2 parents 5bc6892 + fdf6fcc commit 515d0e1
Show file tree
Hide file tree
Showing 83 changed files with 2,385 additions and 3,204 deletions.
3 changes: 3 additions & 0 deletions LibAoe2AISharp/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ csharp_style_var_when_type_is_apparent = false:none

# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = none

# IDE0055: Fix formatting
dotnet_diagnostic.IDE0055.severity = none
1 change: 0 additions & 1 deletion LibAoe2AISharp/Framework/Actions/Train/TrainVillager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LibAoe2AISharp.Specifications;
using static LibAoe2AISharp.Specifications.Ope;

namespace LibAoe2AISharp.Framework
{
Expand Down
4 changes: 2 additions & 2 deletions LibAoe2AISharp/Framework/Ages/AgeStateCollection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using LibAoe2AISharp.Specifications;

using LibAoe2AISharp.Specifications;

namespace LibAoe2AISharp.Framework
{
/// <summary>
Expand Down
40 changes: 20 additions & 20 deletions LibAoe2AISharp/Framework/Ages/EnterAge.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using LibAoe2AISharp.Specifications;
using static LibAoe2AISharp.Framework.AgeStateCollection;

namespace LibAoe2AISharp.Framework
{
/// <summary>
/// Basic control after reserching the age.
/// </summary>
public abstract class EnterAge : defrule
{
/// <summary>
/// Initializes a new instance of the <see cref="EnterAge"/> class.
/// </summary>
protected EnterAge()
{
Actions.Add(
new set_goal(AgeState, Transitioned),
new disable_self());
}
}
using LibAoe2AISharp.Specifications;
using static LibAoe2AISharp.Framework.AgeStateCollection;

namespace LibAoe2AISharp.Framework
{
/// <summary>
/// Basic control after reserching the age.
/// </summary>
public abstract class EnterAge : defrule
{
/// <summary>
/// Initializes a new instance of the <see cref="EnterAge"/> class.
/// </summary>
protected EnterAge()
{
Actions.Add(
new set_goal(AgeState, Transitioned),
new disable_self());
}
}
}
82 changes: 41 additions & 41 deletions LibAoe2AISharp/Framework/Ages/ResearchState.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
namespace LibAoe2AISharp.Framework
{
/// <summary>
/// research state.
/// </summary>
public enum ResearchState
{
/// <summary>
/// Research finished.
/// </summary>
Finished,

/// <summary>
/// Researching.
/// </summary>
Researching,

/// <summary>
/// Not researching now.
/// </summary>
NotResearching,
}

/// <summary>
/// valid wall perimeter.
/// <para>
/// 1 is closer to the Town Center than 2.
/// </para>
/// </summary>
public enum Perimeter
{
/// <summary>
/// Perimeter 1 is usually between 10 and 20 tiles from the starting Town Center.
/// </summary>
Near = 1,

/// <summary>
/// Perimeter 2 is usually between 18 and 30 tiles from the starting Town Center.
/// </summary>
Far = 2,
}
namespace LibAoe2AISharp.Framework
{
/// <summary>
/// research state.
/// </summary>
public enum ResearchState
{
/// <summary>
/// Research finished.
/// </summary>
Finished,

/// <summary>
/// Researching.
/// </summary>
Researching,

/// <summary>
/// Not researching now.
/// </summary>
NotResearching,
}

/// <summary>
/// valid wall perimeter.
/// <para>
/// 1 is closer to the Town Center than 2.
/// </para>
/// </summary>
public enum Perimeter
{
/// <summary>
/// Perimeter 1 is usually between 10 and 20 tiles from the starting Town Center.
/// </summary>
Near = 1,

/// <summary>
/// Perimeter 2 is usually between 18 and 30 tiles from the starting Town Center.
/// </summary>
Far = 2,
}
}
23 changes: 16 additions & 7 deletions LibAoe2AISharp/Framework/Commands/EachAgesCommandCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,22 @@ public enum GroupType

private static string GetTransitionstring(ResearchState researchOption, age targetAge)
{
var ret = researchOption switch
{
ResearchState.Finished => targetAge.ToLocalLang(),
ResearchState.Researching => (targetAge + 1).ToLocalLang(),
ResearchState.NotResearching => targetAge.ToLocalLang(),
_ => throw new ArgumentOutOfRangeException(nameof(researchOption)),
};
string ret;

switch (researchOption) {
case ResearchState.Finished:
ret = targetAge.ToLocalLang();
break;
case ResearchState.Researching:
ret = (targetAge + 1).ToLocalLang();
break;
case ResearchState.NotResearching:
ret = targetAge.ToLocalLang();
break;
default:
throw new ArgumentOutOfRangeException(nameof(researchOption));
}

return ret + " " + researchOption.ToLocalLang();
}

Expand Down
7 changes: 3 additions & 4 deletions LibAoe2AISharp/Framework/Files/AIFile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using LibAoe2AISharp.Specifications;
Expand All @@ -26,7 +25,7 @@ protected AIFile(string pathName, string author, params PerFile[] relatedFiles)

// Add related files.
foreach (var item in relatedFiles) {
item.Author ??= author;
item.Author = item.Author ?? author;
item.ParentFile = this;
RelatedFiles.Add(item);

Expand Down Expand Up @@ -155,7 +154,7 @@ public ShowFirstChatMessage(string message)
Facts.Add(new game_time(relop.ge, 10));

// Set the message to the chat command each \r\n.
foreach (var item in message.Replace("\r\n", "\n", StringComparison.Ordinal).Split('\n')) {
foreach (var item in message.Replace("\r\n", "\n").Split('\n')) {
if (!string.IsNullOrWhiteSpace(item)) {
Actions.Add(new chat_local_to_self(item));
}
Expand Down
4 changes: 2 additions & 2 deletions LibAoe2AISharp/Framework/Files/PerFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public abstract class PerFile : PerFileGenerator
/// <summary>
/// Gets file name without extention.
/// </summary>
public override string FileName => ParentFile?.FileName + GetType().Name;

public override string FileName => ParentFile?.FileName + GetType().Name;

/// <summary>
/// Gets or Sets path name of AI script file.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions LibAoe2AISharp/Framework/Goals/goal.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using LibAoe2AISharp.Specifications;
using LibAoe2AISharp.Specifications;

namespace LibAoe2AISharp.Framework
{
Expand Down
144 changes: 72 additions & 72 deletions LibAoe2AISharp/Framework/Research/Research.cs
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
using LibAoe2AISharp.Specifications;
using LibAoe2AISharp.Utilty;
using static LibAoe2AISharp.Specifications.Ope;

namespace LibAoe2AISharp.Framework
{
/// <summary>
/// Basic control of research action.
/// Confirm that the unit can be researching and research.
/// </summary>
public class Research : defrule
{
/// <summary>
/// Initializes a new instance of the <see cref="Research"/> class.
/// </summary>
/// <param name="researchAge">research age.</param>
public Research(age researchAge)
{
Comment = "Research " + researchAge.ToLocalLang();
Facts.Add(new can_research(researchAge));
Actions.Add(new research(researchAge));
ResearchAge = researchAge;
ResearchItem = ri.Unknown;
}

/// <summary>
/// Initializes a new instance of the <see cref="Research"/> class.
/// </summary>
/// <param name="researchItem">research technology.</param>
public Research(ri researchItem)
{
Comment = "Research " + researchItem.ToLocalLang();
Facts.Add(new can_research(researchItem));
Actions.Add(new research(researchItem));
ResearchItem = researchItem;
ResearchAge = age.Unknown;
}

/// <summary>
/// Initializes a new instance of the <see cref="Research"/> class.
/// <para>
/// Research item if the given unit is greater than or equal to the given count.
/// </para>
/// </summary>
/// <param name="researchItem">research item.</param>
/// <param name="unit">unit.</param>
/// <param name="count">unit count.</param>
public Research(ri researchItem, unit unit, short count)
{
Comment = "Research " + researchItem.ToLocalLang() + " :"
+ unit.ToLocalLang() + " up to " + count;

Facts.Add(
new can_research(researchItem),
new unit_type_count_total(unit, relop.ge, count));

Actions.Add(new research(researchItem));
ResearchItem = researchItem;
ResearchAge = age.Unknown;
}

/// <summary>
/// Gets research technology.
/// </summary>
public ri ResearchItem { get; } = ri.Unknown;

/// <summary>
/// Gets research age.
/// </summary>
public age ResearchAge { get; } = age.Unknown;
}
}
using LibAoe2AISharp.Specifications;
using LibAoe2AISharp.Utilty;
using static LibAoe2AISharp.Specifications.Ope;

namespace LibAoe2AISharp.Framework
{
/// <summary>
/// Basic control of research action.
/// Confirm that the unit can be researching and research.
/// </summary>
public class Research : defrule
{
/// <summary>
/// Initializes a new instance of the <see cref="Research"/> class.
/// </summary>
/// <param name="researchAge">research age.</param>
public Research(age researchAge)
{
Comment = "Research " + researchAge.ToLocalLang();
Facts.Add(new can_research(researchAge));
Actions.Add(new research(researchAge));
ResearchAge = researchAge;
ResearchItem = ri.Unknown;
}

/// <summary>
/// Initializes a new instance of the <see cref="Research"/> class.
/// </summary>
/// <param name="researchItem">research technology.</param>
public Research(ri researchItem)
{
Comment = "Research " + researchItem.ToLocalLang();
Facts.Add(new can_research(researchItem));
Actions.Add(new research(researchItem));
ResearchItem = researchItem;
ResearchAge = age.Unknown;
}

/// <summary>
/// Initializes a new instance of the <see cref="Research"/> class.
/// <para>
/// Research item if the given unit is greater than or equal to the given count.
/// </para>
/// </summary>
/// <param name="researchItem">research item.</param>
/// <param name="unit">unit.</param>
/// <param name="count">unit count.</param>
public Research(ri researchItem, unit unit, short count)
{
Comment = "Research " + researchItem.ToLocalLang() + " :"
+ unit.ToLocalLang() + " up to " + count;

Facts.Add(
new can_research(researchItem),
new unit_type_count_total(unit, relop.ge, count));

Actions.Add(new research(researchItem));
ResearchItem = researchItem;
ResearchAge = age.Unknown;
}

/// <summary>
/// Gets research technology.
/// </summary>
public ri ResearchItem { get; } = ri.Unknown;

/// <summary>
/// Gets research age.
/// </summary>
public age ResearchAge { get; } = age.Unknown;
}
}
Loading

0 comments on commit 515d0e1

Please sign in to comment.