├── GameFiles ├── Images │ ├── Monsters │ │ ├── Rat.png │ │ ├── Snake.png │ │ └── GiantSpider.png │ └── Locations │ │ ├── Home.png │ │ ├── TownGate.png │ │ ├── Trader.png │ │ ├── FarmFields.png │ │ ├── Farmhouse.png │ │ ├── TownSquare.png │ │ ├── HerbalistsHut.png │ │ ├── SpiderForest.png │ │ └── HerbalistsGarden.png └── GameData │ ├── Recipes.xml │ ├── Quests.xml │ ├── Traders.xml │ ├── Monsters.xml │ ├── GameItems.xml │ ├── GameDetails.json │ └── Locations.xml ├── SOSCSRPG.Models ├── EventArgs │ └── CombatVictoryEventArgs.cs ├── FodyWeavers.xml ├── PlayerAttributeModifier.cs ├── Actions │ ├── IAction.cs │ ├── BaseAction.cs │ ├── Heal.cs │ └── AttackWithWeapon.cs ├── ItemPercentage.cs ├── Trader.cs ├── Race.cs ├── MonsterEncounter.cs ├── GameState.cs ├── QuestStatus.cs ├── GroupedInventoryItem.cs ├── ItemQuantity.cs ├── PopupDetails.cs ├── SOSCSRPG.Models.csproj ├── GameDetails.cs ├── World.cs ├── Recipe.cs ├── GameItem.cs ├── Monster.cs ├── Location.cs ├── PlayerAttribute.cs ├── Shared │ └── ExtensionMethods.cs ├── Quest.cs ├── Player.cs ├── FodyWeavers.xsd ├── Battle.cs ├── Inventory.cs └── LivingEntity.cs ├── Engine ├── FodyWeavers.xml ├── app.config ├── Engine.csproj └── FodyWeavers.xsd ├── SOSCSRPG.ViewModels ├── FodyWeavers.xml ├── SOSCSRPG.ViewModels.csproj ├── CharacterCreationViewModel.cs ├── FodyWeavers.xsd └── GameSession.cs ├── SOSCSRPG.Core ├── GameMessageEventArgs.cs ├── SOSCSRPG.Core.csproj ├── IDiceService.cs ├── MessageBroker.cs ├── LoggingService.cs └── DiceService.cs ├── SOSCSRPG.Services ├── SOSCSRPG.Services.csproj ├── Factories │ ├── TraderFactory.cs │ ├── RecipeFactory.cs │ ├── QuestFactory.cs │ ├── ItemFactory.cs │ ├── WorldFactory.cs │ └── MonsterFactory.cs ├── GameDetailsService.cs └── SaveGameService.cs ├── SOSCSRPG.sln.DotSettings ├── WPFUI ├── WPFUI.csproj.user ├── AssemblyInfo.cs ├── App.xaml ├── WPFUI.csproj ├── App.xaml.cs ├── Windows │ ├── YesNoWindow.xaml.cs │ └── YesNoWindow.xaml ├── CharacterCreation.xaml.cs ├── CustomConverters │ └── FileToBitmapConverter.cs ├── Startup.xaml ├── App.config ├── Startup.xaml.cs ├── TradeScreen.xaml.cs ├── CharacterCreation.xaml ├── TradeScreen.xaml ├── MainWindow.xaml.cs └── MainWindow.xaml ├── README.md ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── LICENSE ├── contributing.md ├── .gitattributes ├── SOSCSRPG.sln ├── Docs └── LicensesConsumed.md └── .gitignore /GameFiles/Images/Monsters/Rat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Monsters/Rat.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/Home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/Home.png -------------------------------------------------------------------------------- /GameFiles/Images/Monsters/Snake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Monsters/Snake.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/TownGate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/TownGate.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/Trader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/Trader.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/FarmFields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/FarmFields.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/Farmhouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/Farmhouse.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/TownSquare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/TownSquare.png -------------------------------------------------------------------------------- /GameFiles/Images/Monsters/GiantSpider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Monsters/GiantSpider.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/HerbalistsHut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/HerbalistsHut.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/SpiderForest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/SpiderForest.png -------------------------------------------------------------------------------- /GameFiles/Images/Locations/HerbalistsGarden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLilly/SOSCSRPG/HEAD/GameFiles/Images/Locations/HerbalistsGarden.png -------------------------------------------------------------------------------- /SOSCSRPG.Models/EventArgs/CombatVictoryEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Models.EventArgs 2 | { 3 | public class CombatVictoryEventArgs : System.EventArgs 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Engine/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SOSCSRPG.ViewModels/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/PlayerAttributeModifier.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Models 2 | { 3 | public class PlayerAttributeModifier 4 | { 5 | public string AttributeKey { get; init; } 6 | public int Modifier { get; init; } 7 | } 8 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/Actions/IAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SOSCSRPG.Models; 3 | 4 | namespace SOSCSRPG.Models.Actions 5 | { 6 | public interface IAction 7 | { 8 | event EventHandler OnActionPerformed; 9 | void Execute(LivingEntity actor, LivingEntity target); 10 | } 11 | } -------------------------------------------------------------------------------- /SOSCSRPG.Core/GameMessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Core 2 | { 3 | public class GameMessageEventArgs : System.EventArgs 4 | { 5 | public string Message { get; private set; } 6 | 7 | public GameMessageEventArgs(string message) 8 | { 9 | Message = message; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/ItemPercentage.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Models 2 | { 3 | public class ItemPercentage 4 | { 5 | public int ID { get; } 6 | public int Percentage { get; } 7 | 8 | public ItemPercentage(int id, int percentage) 9 | { 10 | ID = id; 11 | Percentage = percentage; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/Trader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class Trader : LivingEntity 6 | { 7 | public int ID { get; } 8 | 9 | public Trader(int id, string name) : base(name, 9999, 9999, new List(), 9999) 10 | { 11 | ID = id; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/Race.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class Race 6 | { 7 | public string Key { get; set; } 8 | public string DisplayName { get; set; } 9 | public List PlayerAttributeModifiers { get; } = 10 | new List(); 11 | } 12 | } -------------------------------------------------------------------------------- /SOSCSRPG.Core/SOSCSRPG.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /SOSCSRPG.Services/SOSCSRPG.Services.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /SOSCSRPG.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /GameFiles/GameData/Recipes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/MonsterEncounter.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Models 2 | { 3 | public class MonsterEncounter 4 | { 5 | public int MonsterID { get; } 6 | public int ChanceOfEncountering { get; set; } 7 | 8 | public MonsterEncounter(int monsterID, int chanceOfEncountering) 9 | { 10 | MonsterID = monsterID; 11 | ChanceOfEncountering = chanceOfEncountering; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /WPFUI/WPFUI.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Designer 7 | 8 | 9 | 10 | 11 | Designer 12 | 13 | 14 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/GameState.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Models 2 | { 3 | public class GameState 4 | { 5 | public Player Player { get; init; } 6 | public int XCoordinate { get; init; } 7 | public int YCoordinate { get; init; } 8 | 9 | public GameState(Player player, int xCoordinate, int yCoordinate) 10 | { 11 | Player = player; 12 | XCoordinate = xCoordinate; 13 | YCoordinate = yCoordinate; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /GameFiles/GameData/Quests.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/QuestStatus.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class QuestStatus : INotifyPropertyChanged 6 | { 7 | public event PropertyChangedEventHandler PropertyChanged; 8 | 9 | public Quest PlayerQuest { get; } 10 | public bool IsCompleted { get; set; } 11 | 12 | public QuestStatus(Quest quest) 13 | { 14 | PlayerQuest = quest; 15 | IsCompleted = false; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SOSCSRPG - Scott's Open-Source C# Role-Playing Game 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
While I still answer questions about this project, it is no longer being changed and has been archived to read-only mode.

Please contact me if you want it reopened.
10 | 11 | A simple role-playing game, written with C# and WPF. 12 | 13 | 14 | Lesson details: https://soscsrpg.com/ 15 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/GroupedInventoryItem.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class GroupedInventoryItem : INotifyPropertyChanged 6 | { 7 | public event PropertyChangedEventHandler PropertyChanged; 8 | 9 | public GameItem Item { get; set; } 10 | public int Quantity { get; set; } 11 | 12 | public GroupedInventoryItem(GameItem item, int quantity) 13 | { 14 | Item = item; 15 | Quantity = quantity; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/ItemQuantity.cs: -------------------------------------------------------------------------------- 1 | namespace SOSCSRPG.Models 2 | { 3 | public class ItemQuantity 4 | { 5 | private readonly GameItem _gameItem; 6 | 7 | public int ItemID => _gameItem.ItemTypeID; 8 | public int Quantity { get; } 9 | 10 | public string QuantityItemDescription => 11 | $"{Quantity} {_gameItem.Name}"; 12 | 13 | public ItemQuantity(GameItem item, int quantity) 14 | { 15 | _gameItem = item; 16 | Quantity = quantity; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/PopupDetails.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class PopupDetails : INotifyPropertyChanged 6 | { 7 | public bool IsVisible { get; set; } 8 | public int Top { get; set; } 9 | public int Left { get; set; } 10 | public int MinHeight { get; set; } 11 | public int MaxHeight { get; set; } 12 | public int MinWidth { get; set; } 13 | public int MaxWidth { get; set; } 14 | 15 | public event PropertyChangedEventHandler PropertyChanged; 16 | } 17 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/Actions/BaseAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SOSCSRPG.Models; 3 | 4 | namespace SOSCSRPG.Models.Actions 5 | { 6 | public abstract class BaseAction 7 | { 8 | protected readonly GameItem _itemInUse; 9 | 10 | public event EventHandler OnActionPerformed; 11 | 12 | protected BaseAction(GameItem itemInUse) 13 | { 14 | _itemInUse = itemInUse; 15 | } 16 | 17 | protected void ReportResult(string result) 18 | { 19 | OnActionPerformed?.Invoke(this, result); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /GameFiles/GameData/Traders.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /WPFUI/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /WPFUI/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Additional context** 27 | Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/SOSCSRPG.Models.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | all 10 | runtime; build; native; contentfiles; analyzers; buildtransitive 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /SOSCSRPG.Models/GameDetails.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class GameDetails 6 | { 7 | public string Title { get; } 8 | public string SubTitle { get; } 9 | public string Version { get; } 10 | 11 | public List PlayerAttributes { get; } = 12 | new List(); 13 | public List Races { get; } = 14 | new List(); 15 | 16 | public GameDetails(string title, string subTitle, string version) 17 | { 18 | Title = title; 19 | SubTitle = subTitle; 20 | Version = version; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /WPFUI/WPFUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net5.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WPFUI/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Threading; 3 | using SOSCSRPG.Core; 4 | 5 | namespace WPFUI 6 | { 7 | public partial class App : Application 8 | { 9 | private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) 10 | { 11 | string exceptionMessageText = 12 | $"An exception occurred: {e.Exception.Message}\r\n\r\nat: {e.Exception.StackTrace}"; 13 | 14 | LoggingService.Log(e.Exception); 15 | 16 | // TODO: Create a Window to display the exception information. 17 | MessageBox.Show(exceptionMessageText, "Unhandled Exception", MessageBoxButton.OK); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /SOSCSRPG.Core/IDiceService.cs: -------------------------------------------------------------------------------- 1 | using D20Tek.DiceNotation; 2 | using D20Tek.DiceNotation.DieRoller; 3 | 4 | namespace SOSCSRPG.Core 5 | { 6 | public interface IDiceService 7 | { 8 | IDice Dice { get; } 9 | 10 | IDiceConfiguration Configuration { get; } 11 | 12 | IDieRollTracker RollTracker { get; } 13 | 14 | void Configure(RollerType rollerType, bool enableTracker = false, int constantValue = 1); 15 | 16 | DiceResult Roll(string diceNotation); 17 | 18 | DiceResult Roll(int sides, int numDice = 1, int modifier = 0); 19 | } 20 | 21 | public enum RollerType 22 | { 23 | Random = 0, 24 | Crypto = 1, 25 | MathNet = 2, 26 | Constant = 3 27 | } 28 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/World.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SOSCSRPG.Models 4 | { 5 | public class World 6 | { 7 | private readonly List _locations = new List(); 8 | 9 | public void AddLocation(Location location) 10 | { 11 | _locations.Add(location); 12 | } 13 | 14 | public Location LocationAt(int xCoordinate, int yCoordinate) 15 | { 16 | foreach(Location loc in _locations) 17 | { 18 | if(loc.XCoordinate == xCoordinate && loc.YCoordinate == yCoordinate) 19 | { 20 | return loc; 21 | } 22 | } 23 | 24 | return null; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /WPFUI/Windows/YesNoWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace WPFUI.Windows 4 | { 5 | public partial class YesNoWindow : Window 6 | { 7 | public bool ClickedYes { get; private set; } 8 | 9 | public YesNoWindow(string title, string message) 10 | { 11 | InitializeComponent(); 12 | 13 | Title = title; 14 | Message.Content = message; 15 | } 16 | 17 | private void Yes_OnClick(object sender, RoutedEventArgs e) 18 | { 19 | ClickedYes = true; 20 | Close(); 21 | } 22 | 23 | private void No_OnClick(object sender, RoutedEventArgs e) 24 | { 25 | ClickedYes = false; 26 | Close(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SOSCSRPG.ViewModels/SOSCSRPG.ViewModels.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | all 10 | runtime; build; native; contentfiles; analyzers; buildtransitive 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /SOSCSRPG.Core/MessageBroker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SOSCSRPG.Core 4 | { 5 | public class MessageBroker 6 | { 7 | // Use the Singleton design pattern for this class, 8 | // to ensure everything in the game sends messages through this one object. 9 | private static readonly MessageBroker s_messageBroker = 10 | new MessageBroker(); 11 | 12 | private MessageBroker() 13 | { 14 | } 15 | 16 | public event EventHandler OnMessageRaised; 17 | 18 | public static MessageBroker GetInstance() 19 | { 20 | return s_messageBroker; 21 | } 22 | 23 | public void RaiseMessage(string message) 24 | { 25 | OnMessageRaised?.Invoke(this, new GameMessageEventArgs(message)); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /GameFiles/GameData/Monsters.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 5 | 6 | 7 | 8 | 9 | 10 | 11 | 8 12 | 13 | 14 | 15 | 16 | 17 | 18 | 12 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /WPFUI/CharacterCreation.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using SOSCSRPG.ViewModels; 4 | 5 | namespace WPFUI 6 | { 7 | public partial class CharacterCreation : Window 8 | { 9 | private CharacterCreationViewModel VM { get; set; } 10 | 11 | public CharacterCreation() 12 | { 13 | InitializeComponent(); 14 | 15 | VM = new CharacterCreationViewModel(); 16 | DataContext = VM; 17 | } 18 | 19 | private void RandomPlayer_OnClick(object sender, RoutedEventArgs e) 20 | { 21 | VM.RollNewCharacter(); 22 | } 23 | 24 | private void UseThisPlayer_OnClick(object sender, RoutedEventArgs e) 25 | { 26 | MainWindow mainWindow = new MainWindow(VM.GetPlayer()); 27 | mainWindow.Show(); 28 | Close(); 29 | } 30 | 31 | private void Race_OnSelectionChanged(object sender, SelectionChangedEventArgs e) 32 | { 33 | VM.ApplyAttributeModifiers(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/Actions/Heal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SOSCSRPG.Models; 3 | 4 | namespace SOSCSRPG.Models.Actions 5 | { 6 | public class Heal : BaseAction, IAction 7 | { 8 | private readonly int _hitPointsToHeal; 9 | 10 | public Heal(GameItem itemInUse, int hitPointsToHeal) 11 | : base(itemInUse) 12 | { 13 | if (itemInUse.Category != GameItem.ItemCategory.Consumable) 14 | { 15 | throw new ArgumentException($"{itemInUse.Name} is not consumable"); 16 | } 17 | 18 | _hitPointsToHeal = hitPointsToHeal; 19 | } 20 | 21 | public void Execute(LivingEntity actor, LivingEntity target) 22 | { 23 | string actorName = (actor is Player) ? "You" : $"The {actor.Name.ToLower()}"; 24 | string targetName = (target is Player) ? "yourself" : $"the {target.Name.ToLower()}"; 25 | 26 | ReportResult($"{actorName} heal {targetName} for {_hitPointsToHeal} point{(_hitPointsToHeal > 1 ? "s" : "")}."); 27 | target.Heal(_hitPointsToHeal); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Scott Lilly 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /GameFiles/GameData/GameItems.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /WPFUI/CustomConverters/FileToBitmapConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | using System.Windows.Media.Imaging; 6 | 7 | namespace WPFUI.CustomConverters 8 | { 9 | public class FileToBitmapConverter : IValueConverter 10 | { 11 | private static readonly Dictionary _locations = 12 | new Dictionary(); 13 | 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if(!(value is string filename)) 17 | { 18 | return null; 19 | } 20 | 21 | if(!_locations.ContainsKey(filename)) 22 | { 23 | _locations.Add(filename, 24 | new BitmapImage(new Uri($"{AppDomain.CurrentDomain.BaseDirectory}{filename}", 25 | UriKind.Absolute))); 26 | } 27 | 28 | return _locations[filename]; 29 | } 30 | 31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 32 | { 33 | return null; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/Recipe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Newtonsoft.Json; 5 | 6 | namespace SOSCSRPG.Models 7 | { 8 | public class Recipe 9 | { 10 | public int ID { get; } 11 | [JsonIgnore] 12 | public string Name { get; } 13 | 14 | [JsonIgnore] public List Ingredients { get; } 15 | [JsonIgnore] 16 | public List OutputItems { get; } 17 | 18 | [JsonIgnore] 19 | public string ToolTipContents => 20 | "Ingredients" + Environment.NewLine + 21 | "===========" + Environment.NewLine + 22 | string.Join(Environment.NewLine, Ingredients.Select(i => i.QuantityItemDescription)) + 23 | Environment.NewLine + Environment.NewLine + 24 | "Creates" + Environment.NewLine + 25 | "===========" + Environment.NewLine + 26 | string.Join(Environment.NewLine, OutputItems.Select(i => i.QuantityItemDescription)); 27 | 28 | public Recipe(int id, string name, List ingredients, List outputItems) 29 | { 30 | ID = id; 31 | Name = name; 32 | Ingredients = ingredients; 33 | OutputItems = outputItems; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SOSCSRPG.Models/GameItem.cs: -------------------------------------------------------------------------------- 1 | using SOSCSRPG.Models.Actions; 2 | using Newtonsoft.Json; 3 | 4 | namespace SOSCSRPG.Models 5 | { 6 | public class GameItem 7 | { 8 | public enum ItemCategory 9 | { 10 | Miscellaneous, 11 | Weapon, 12 | Consumable 13 | } 14 | 15 | [JsonIgnore] 16 | public ItemCategory Category { get; } 17 | public int ItemTypeID { get; } 18 | [JsonIgnore] 19 | public string Name { get; } 20 | [JsonIgnore] 21 | public int Price { get; } 22 | [JsonIgnore] 23 | public bool IsUnique { get; } 24 | [JsonIgnore] 25 | public IAction Action { get; set; } 26 | 27 | public GameItem(ItemCategory category, int itemTypeID, string name, int price, 28 | bool isUnique = false, IAction action = null) 29 | { 30 | Category = category; 31 | ItemTypeID = itemTypeID; 32 | Name = name; 33 | Price = price; 34 | IsUnique = isUnique; 35 | Action = action; 36 | } 37 | 38 | public void PerformAction(LivingEntity actor, LivingEntity target) 39 | { 40 | Action?.Execute(actor, target); 41 | } 42 | 43 | public GameItem Clone() 44 | { 45 | return new GameItem(Category, ItemTypeID, Name, Price, IsUnique, Action); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /WPFUI/Windows/YesNoWindow.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 220 | 221 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 290 | 291 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 363 | 364 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 527 | 528 | 535 | 536 | 540 | 541 | 542 | 543 | 544 | 545 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 560 | 561 | 568 | 569 | 573 | Current Hit Points: 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 619 | 620 |