Merge pull request '✏️♻️🏗️📦🩹 fix-stub-merge' (#54) from fix-stub-merge into main
continuous-integration/drone/push Build is passing Details

Reviewed-on: #54
pull/55/head
Alexis Drai 2 years ago
commit f947a4fea5

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
namespace Data
{
public interface ILoader
{
public GameRunner LoadApp();
}
}

@ -0,0 +1,97 @@
using Data;
using Model;
namespace Stub
{
public class Stub : ILoader
{
// when the other classes are ready
// the Stub should just make and return a GameRunner, and the GameRunner should have
// a PlayerManager, a collection of Games, a FavGroupManager, etc. (see diagram)
public GameRunner LoadApp()
{
// this doesn't do much for now, because the class isn't coded
return new GameRunner();
}
public static List<Player> LoadPlayers()
{
List<Player> list = new()
{
new Player("name 1"),
new Player("name 2"),
new Player("name 3"),
new Player("name 4"),
new Player("name 5"),
new Player("name 6")
};
return list;
}
public static List<Die> LoadDices()
{
List<Die> list = new()
{
new Die("Dice 1"),
new Die("Dice 1"),
new Die("Dice 1"),
new Die("Dice 1"),
new Die("Dice 1"),
new Die("Dice 1")
};
return list;
}
public static List<NumberDieFace> LoadNumFaces()
{
List<NumberDieFace> list = new()
{
new NumberDieFace(1),
new NumberDieFace(2),
new NumberDieFace(3),
new NumberDieFace(4),
new NumberDieFace(5),
new NumberDieFace(6),
new NumberDieFace(7)
};
return list;
}
public static List<ColorDieFace> LoadClrFaces()
{
List<ColorDieFace> list = new()
{
new ColorDieFace("ffffff"),
new ColorDieFace("ffff66"),
new ColorDieFace("ffff11"),
new ColorDieFace("ffff22"),
new ColorDieFace("ffff33"),
new ColorDieFace("ffff44"),
new ColorDieFace("ffff55")
};
return list;
}
public static List<ImageDieFace> LoadImgFaces()
{
string urlBase = "baseUrl/img/";
List<ImageDieFace> list = new()
{
new ImageDieFace( urlBase + 1),
new ImageDieFace( urlBase + 2),
new ImageDieFace( urlBase + 3),
new ImageDieFace( urlBase + 4),
new ImageDieFace( urlBase + 5),
new ImageDieFace( urlBase + 6),
new ImageDieFace( urlBase + 7),
};
return list;
}
}
}

@ -12,7 +12,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App", "App\App.csproj", "{8
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{11BDDDA8-CBED-46EE-A224-144C3CD545A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stub", "Stub\Stub.csproj", "{3047BFD8-EF44-4095-9E54-45D47C7AB212}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Data", "Data\Data.csproj", "{3047BFD8-EF44-4095-9E54-45D47C7AB212}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{953D2D67-BCE7-412C-B7BB-7C63B5592359}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public abstract class AbstractDieFace
{
/// <summary>
/// every die face has a value, and they can all be represented by an int,
/// even if they're not litterally a decimal number
/// <br/>
/// USE GetPracticalValue for a Value specific to face type
/// </summary>
protected abstract int Value { get; }
public abstract object GetPracticalValue();
}
}

@ -6,16 +6,39 @@ using System.Threading.Tasks;
namespace Model
{
public class ColorDieFace : IDieFace
public class ColorDieFace : AbstractDieFace
{
private string ColorHex;
/// <summary>
/// a decimal representation of the hex (...representation of the color)
/// </summary>
protected override int Value { get; }
public ColorDieFace(string v)
/// <summary>
/// accepts hex strings like "ffbb84" ([RRGGBB])
/// </summary>
/// <param name="hexValueString">hex string</param>
public ColorDieFace(string hexValueString)
{
this.ColorHex = v;
// https://stackoverflow.com/questions/1139957/convert-integer-to-hexadecimal-and-back-again
// if style is ("f0b"), this constructor can develop it to "ff00bb" before doing the job
Value = int.Parse(hexValueString, System.Globalization.NumberStyles.HexNumber);
}
public string getColorHex() { return ColorHex; }
public void setColorHex(string ColorHex) { this.ColorHex = ColorHex; }
/// <summary>
/// accepts a decimal value that represents a color hex (0 is black, 65280 is green...)
/// </summary>
/// <param name="decimalValue"></param>
public ColorDieFace(int decimalValue)
{
Value = decimalValue;
}
public override object GetPracticalValue()
{
// https://stackoverflow.com/questions/1139957/convert-integer-to-hexadecimal-and-back-again
// maybe prepend it with a "#"...
return Value.ToString("X");
}
}
}

@ -6,8 +6,7 @@ using System.Threading.Tasks;
namespace Model
{
public abstract class IDieFace
public class GameRunner
{
public string ID { get; set; }
}
}

@ -6,16 +6,30 @@ using System.Threading.Tasks;
namespace Model
{
public class ImageDieFace : IDieFace
public class ImageDieFace : AbstractDieFace
{
private string ImageUrlCode;
/// <summary>
/// an image URL code, to find the image URL (to find the image)
/// </summary>
protected override int Value { get; }
public ImageDieFace(string v)
public ImageDieFace(string uri)
{
this.ImageUrlCode = v;
/*parse an int after the last occurrence of "/" ? */
string resultString = uri[(uri.LastIndexOf('/') + 1)..];
/* !! here we should make sure to remove any ".jpg" etc, if there was one in the uri*/
int result = int.Parse(resultString);
Value = result;
}
public string getImageUrlCode() { return ImageUrlCode; }
public void setImageUrlCode(string ImageUrlCode) { this.ImageUrlCode = ImageUrlCode; }
public ImageDieFace(int code)
{
Value = code;
}
public override object GetPracticalValue()
{
return String.Format("Assets/images/{0}", Value);
}
}
}

@ -6,17 +6,17 @@ using System.Threading.Tasks;
namespace Model
{
public class NumberDieFace : IDieFace
public class NumberDieFace : AbstractDieFace
{
public int Num { get; set; }
public NumberDieFace(int v)
protected override int Value { get; }
public NumberDieFace(int value)
{
this.Num = v;
Value = value;
}
public override object GetPracticalValue()
{
return Value;
}
}
}

@ -1,76 +0,0 @@
using Model;
namespace Stub
{
public class Stub
{
public List<Player> LoadPlayers()
{
List<Player> list = new List<Player>();
list.Add(new Player("name 1"));
list.Add(new Player("name 2"));
list.Add(new Player("name 3"));
list.Add(new Player("name 4"));
list.Add(new Player("name 5"));
list.Add(new Player("name 6"));
return list;
}
public List<Die> LoadDices()
{
List<Die> list = new List<Die>();
list.Add(new Die("Dice 1"));
list.Add(new Die("Dice 1"));
list.Add(new Die("Dice 1"));
list.Add(new Die("Dice 1"));
list.Add(new Die("Dice 1"));
list.Add(new Die("Dice 1"));
return list;
}
public List<NumberDieFace> LoadNumFaces()
{
List<NumberDieFace> list = new List<NumberDieFace>();
list.Add(new NumberDieFace(1));
list.Add(new NumberDieFace(2));
list.Add(new NumberDieFace(3));
list.Add(new NumberDieFace(4));
list.Add(new NumberDieFace(5));
list.Add(new NumberDieFace(6));
list.Add(new NumberDieFace(7));
return list;
}
public List<ColorDieFace> LoadClrFaces()
{
List<ColorDieFace> list = new List<ColorDieFace>();
list.Add(new ColorDieFace("#fff"));
list.Add(new ColorDieFace("#fff66"));
list.Add(new ColorDieFace("#fff11"));
list.Add(new ColorDieFace("#fff22"));
list.Add(new ColorDieFace("#fff33"));
list.Add(new ColorDieFace("#fff44"));
list.Add(new ColorDieFace("#fff55"));
return list;
}
public List<ImageDieFace> LoadImgFaces()
{
List<ImageDieFace> list = new List<ImageDieFace>();
list.Add(new ImageDieFace("http://baseUrl/img/1"));
list.Add(new ImageDieFace("http://baseUrl/img/2"));
list.Add(new ImageDieFace("http://baseUrl/img/3"));
list.Add(new ImageDieFace("http://baseUrl/img/4"));
list.Add(new ImageDieFace("http://baseUrl/img/5"));
list.Add(new ImageDieFace("http://baseUrl/img/6"));
list.Add(new ImageDieFace("http://baseUrl/img/7"));
return list;
}
}
}
Loading…
Cancel
Save