Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy V2.0.0 #30

Merged
merged 25 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8e1acb0
Keep versioning info correct in MAIN.cs
Kerbaltec-Solutions Jul 23, 2023
91724f9
Update dotnet.yml
Kerbaltec-Solutions Jul 23, 2023
305c6ec
Add posibility to save map to file and load map from file
Kerbaltec-Solutions Oct 24, 2023
13dbda9
Merge branch 'dev' of https://github.com/Kerbaltec-Solutions/this_is_…
Kerbaltec-Solutions Oct 24, 2023
a342de1
worker can die now
Kerbaltec-Solutions Oct 26, 2023
35d86cb
update tutorial
Kerbaltec-Solutions Oct 26, 2023
af668fb
Worker now builds Houses, one Worker is created on startup, House cos…
Kerbaltec-Solutions Oct 26, 2023
9834dbc
resources respawn, wildlife only tracks creatures not houses, added i…
Kerbaltec-Solutions Oct 26, 2023
bfb6ed7
fixed map loading/creation
Kerbaltec-Solutions Oct 26, 2023
392b93d
fixed map loading/creation
Kerbaltec-Solutions Oct 26, 2023
940858f
fixed respawn timer
Kerbaltec-Solutions Oct 26, 2023
305a986
Update README.md
Kerbaltec-Solutions Nov 9, 2023
dc8ef17
Update README.md
Kerbaltec-Solutions Nov 9, 2023
30fbe4e
Update README.md
Kerbaltec-Solutions Nov 9, 2023
2e51147
Ver 1.0.7-dev Complete overhaul to resource system. Resource tracker …
Kerbaltec-Solutions Jan 8, 2024
f926d59
ver 1.0.8-dev fixed resource error handling, fixed resources being su…
Jan 9, 2024
4523eb4
Merge branch 'nightly' into dev
Kerbaltec-Solutions Jan 9, 2024
d8ffe42
ver 1.1.0-nightly
Kerbaltec-Solutions Jan 9, 2024
c97aa2e
Fixed exception handeling for entity creation
Kerbaltec-Solutions May 3, 2024
e03f2d6
Merge branch 'dev' of https://github.com/Kerbaltec-Solutions/this_is_…
Kerbaltec-Solutions May 3, 2024
d1fb8eb
deploying v2.0.0
Kerbaltec-Solutions May 31, 2024
7ba14f3
Merge pull request #26 from Kerbaltec-Solutions/dev
Kerbaltec-Solutions May 31, 2024
08f3be8
Merge pull request #27 from Kerbaltec-Solutions/main
Kerbaltec-Solutions May 31, 2024
065b43c
Merge pull request #28 from Kerbaltec-Solutions/main
Kerbaltec-Solutions May 31, 2024
7fbf475
Merge pull request #29 from Kerbaltec-Solutions/dev
Kerbaltec-Solutions May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: .NET

on:
push:
branches: [ "main","dev","nightly","stable" ]
branches: [ "dev","nightly","stable" ]
pull_request:
branches: [ "main","dev","nightly","stable" ]
branches: [ "dev","nightly","stable" ]

jobs:
build:
Expand Down
61 changes: 22 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import: https://github.com/liascript/CodeRunner

-->

[![LiaScript](https://raw.githubusercontent.com/LiaScript/LiaScript/master/badges/course.svg)](https://liascript.github.io/course/?https://github.com/Kerbaltec-Solutions/this_is_MOD-D-ABLE/blob/master/README.md)
[![LiaScript](https://raw.githubusercontent.com/LiaScript/LiaScript/master/badges/course.svg)](https://liascript.github.io/course/?https://github.com/Kerbaltec-Solutions/this_is_MOD-D-ABLE/blob/main/README.md)

![logo](https://github.com/Kerbaltec-Solutions/this_is_MOD-D-ABLE/assets/61379284/6656a1be-4630-4b50-94ab-39ce8dfa382c)

# This is MOD(D)ABLE

In "This is MOD(D)ABLE" the player controls their own tribe, helps it defend itself against wild animals, collect food and resources and grow to new sizes. Game entities can be flexibly added and edited by the player to adapt the game to their own playstyle. "This is MOD(D)ABLE" is played in the console by representing the map using console colors and ASCII characters, and control is done via text commands such as "fighter1:target(X,Y)". The game should be compiled locally to ensure maximum editability.

-- Hier folgt bald ein Teaser-Video --
!?[Teaser](https://youtu.be/KSM9npYXOmA?si=7c-HhC6Mh-OfnPDE)

## Downloads:

Expand All @@ -31,25 +31,26 @@ In "This is MOD(D)ABLE" the player controls their own tribe, helps it defend its
## Useage:

- Download the version, you would like to use.
- open the console
- Navigate inside the folder "this_is_MOD-D-ABLE"
- ensure, you have .NET 6.0 installed
- on first run, first use "dotnet add Package Accord" to install neccesarry Libraries
- start the program by typing "dotnet run"
- press ENTER to switch in and out of the command input mode.
- in the input mode, type sys:help() to view a list of available commands. (not yet implemented)

## Zielsetzung

- Das Ziel ist das erstellen eines Management/Survival-Spiels ähnlich AoE in C# unter berücksichtigung der Modifizierbarkeit durch Dritte in der Zukunft.
- Die Software soll als Sourcecode verteilt werden und erst bei Ausführung lokal compiliert werden.
- Mittels System.Reflexion soll das Programm selbstständig die Funktionen der Entitäten des Spiels aufrufen können.
- Die Steuerung des Spiels erfolgt hauptsächlich über pseudo-funktionsaufrufe, die der Spieler in die Konsole eingibt.
- Um die Konsole zu öffnen und, um den gezeigten Kartenausschnitt zu ändern soll ein asyncroner Input handler mittels System.Threading geschrieben werden.
- Das Spiel soll in Takten die Eigenschaften sämmtlicher Entitäten bearbeiten und zwar über eine Funktion der Entität, die angibt, was geschehen soll.
- Die Karte, mit Ressourcen, Hindernissen und Farben soll mittels Perlin noise aus der Bibliothek Accord zufällig erzeugt werden.
- Entitäten, die auf der Karte gezeigt werden, sollen über einen einzelnen Charakter repräsentiert werden.
- Die Karte soll mittels variation der Hintergrundfarbe in der Konsole gezeichnet werden.
- normal installation mode (only available for Linux):
- ensure, you have .NET 6.X installed
- open the "this_is_MOD-D-ABLE" folder in your file explorer
- for first installation:
- right click on "setup.sh"
- navigate to "properties/Permissions"
- check "Allow executing file as program"
- close the Properties menu and right click on setup.sh again
- click "Run as a Program"
-starting the game after installation:
- right click on "start.sh"
- click "Run as a Program"
- manual installation and running
- open the console
- Navigate inside the folder "this_is_MOD-D-ABLE"
- ensure, you have .NET 6.0 installed
- on first run, first use "dotnet add Package Accord" to install neccesarry Libraries
- start the program by typing "dotnet run"
- press ENTER to switch in and out of the command input mode.
- in the input mode, type sys:help() to view a list of available commands.

## Vorläufiges Dateizusammenhangsdiagramm
<!--
Expand Down Expand Up @@ -82,21 +83,3 @@ style="width: 90%; max-width: 860px; display: block; margin-left: auto; margin-r
+------------------------------------+

````

## Einschränkung im Rahmen der Abschlussarbeit

Es soll nur das Grundgerüst des Spiels sowie folgende Entitäten und Resourcen erstellt werden.

Entitäten:

- Fighter: Kann andere Entitäten umbringen, Kostet Nahrung und Geld
- Worker: Kann Gestein & Ore abbauen, Kostet Nahrung
- Wildlife (friendly): Kann von Fighter getötet werden, enthält Nahrung
- Wildlife (aggresive): Kann andere Entitäten umbringen, Kann von Fighter getötet werden
- Ore: Kann von Worker abgebaut werden, Enthält Geld
- House: Kann Worker und Fighter ausbilden, Kostet Geld

Resourcen:

- Geld: produziert aus Ore von Worker
- Nahrung: produziert aus Wildlife von Fighter
13 changes: 13 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo "for setup, please enter your sudo passwort:"
sudo -s
echo "making startfile executable"
sudo chmod u+r start.sh
echo "adding Accord library"
sudo dotnet add package Accord
echo "install xterm for terminal resizing"
sudo apt-get install xterm
echo "cleaning up"
sudo apt autoremove
./start.sh
35 changes: 5 additions & 30 deletions src/EntityManagement/Entities/AbstractCreature.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
using RoutePlanning;
public abstract class Creature{

protected TIM.main game = null!; // reference go game
public abstract class Creature:Entity{
public bool draw{get;} = true; //if the entity should be drawn on the map
public bool iterate{get;} = true; //if the entity has actions to perform every frame
public abstract bool createByPlayer{get;} //can the entity be created by the player directly

public abstract bool controlledByPlayer{get;} // can the player controll the entity
public abstract char mapChar{get;} //character which will represent the entity on the map
public abstract int mapColor{get;} //color in which the entity will be drawn on the map
protected abstract float speed{get;} //movement speed of the entity in fields per second

protected bool isDead{get;set;} = false;

protected abstract int maxHealthPoints {get;}
protected abstract int healthPoints{get;set;}


public Position position{get;set;} = null!; //current position of the entity
protected Position? target = null; //target position
protected Route? route = null; // currently assigned route
protected functionProperties? tgtEntity = null; // target entity
protected bool trackEntity = false; // is currently following entity
protected float timeSinceLastMove = TIM.main.STEPTIME; // in seconds


//setup function, set position ect.
public virtual void setup(string input, TIM.main game){
this.game = game;
this.position= new Position(Math.Min(int.Parse(input.Split(",")[0]),game.mapsize.X),Math.Min(int.Parse(input.Split(",")[1]),game.mapsize.Y));
this.route = null;
}

// setup for spawning entities at start of game
public virtual void autoSetup(Position pos, TIM.main game){
this.game = game;
this.position = pos;
}

//frame actions
public virtual void step(TIM.main game){
if(isDead){
Expand Down Expand Up @@ -106,16 +84,12 @@ public void getHit(int damage){
healthPoints -= damage;
if(healthPoints <= 0){
isDead = true;

}
}

// functions for player

// prints coordinates of position
public void printPosition(TIM.main game){
Console.WriteLine("{0}",position);
}

// prints current route
public void printRoute(TIM.main game){
if(route != null){
Expand All @@ -128,6 +102,7 @@ public void printRoute(TIM.main game){
// print health points and maximal health points
public void printHP(TIM.main game){
Console.WriteLine("HP: {0} | maxHp: {1}",healthPoints, maxHealthPoints);
Console.WriteLine("Is dead? {0}",isDead);
}

//set a target
Expand All @@ -143,10 +118,10 @@ public void GoTo(string input, TIM.main game){
}

// set new targetEntity
public void GoToEntity(string input, TIM.main game){
public void GoToE(string input, TIM.main game){
// try to find entity
try{
if(controlledByPlayer){
if(controlledByPlayer){
functionProperties entity = game.entities[input];
var boolVar= entity.fType.GetProperty("draw");
if(boolVar!=null){
Expand Down
28 changes: 28 additions & 0 deletions src/EntityManagement/Entities/AbstractEntities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public abstract class Entity{
protected TIM.main game = null!;

public abstract bool createByPlayer{get;} //can the entity be created by the player directly

public abstract bool controlledByPlayer{get;} // can the player controll the entity
public abstract char mapChar{get;} //character which will represent the entity on the map
public abstract int mapColor{get;} //color in which the entity will be drawn on the map

public Position position{get;set;} = null!;

//setup function, set position ect.
public virtual void setup(string input, TIM.main game){
this.game = game;
this.position= new Position(Math.Min(int.Parse(input.Split(",")[0]),game.mapsize.X),Math.Min(int.Parse(input.Split(",")[1]),game.mapsize.Y));
}

// setup for spawning entities at start of game
public virtual void autoSetup(Position pos, TIM.main game){
this.game = game;
this.position = pos;
}

// prints coordinates of position
public void printPosition(TIM.main game){
Console.WriteLine("{0}",position);
}
}
2 changes: 1 addition & 1 deletion src/EntityManagement/Entities/Fighters/AbstractFighter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
public abstract class Fighter :Creature{
public bool isTarget{get;} = true; // creature is target for enemies
protected abstract int damage{get;} // damage the fighter deals per hit
protected abstract int hitRange{get;} // maximal distance to target in which fighter can deal damage

Expand Down Expand Up @@ -71,7 +72,6 @@ public void targetNearestWildlife(TIM.main game){
Console.WriteLine("No Wildlife in range.");
}
}

public void hunt(TIM.main game){
targetNearestWildlife(game);
}
Expand Down
74 changes: 33 additions & 41 deletions src/EntityManagement/Entities/House.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// entity that can be build by player, that is able to spawn entities that are controlled by the player
public class House{
private TIM.main game = null!;
public bool createByPlayer{get;} = true;
using System;
using System.Reflection;
public class House:Entity{

public override bool createByPlayer{get;} = false;
public bool isHouse{get;} = true;
public bool draw{get;} = true;
public char mapChar{get;} = 'H';
public int mapColor{get;} = 4;
public Position position{get;set;} = null!;
public override char mapChar{get;} = 'H';
public override int mapColor{get;} = 4;
public override bool controlledByPlayer{get;} = true; // can the player controll the entity

public void setup(string input, TIM.main g){
game=g;
this.position= new Position(Math.Min(int.Parse(input.Split(",")[0]),game.mapsize.X),Math.Min(int.Parse(input.Split(",")[1]),game.mapsize.Y));
public override void setup(string input, TIM.main g){
base.setup(input, g);
if(!game.gameMap.mapArray[position.X,position.Y].resource.IsWalkable){
throw new NotSupportedException("Position not valid");
}
Expand All @@ -22,45 +23,36 @@ public void setup(string input, TIM.main g){
private int checkMaterials(string entityClass){
switch(entityClass){
case "Worker":{
if(game.materials.Food >= 2){
return 1;
}else{return 0;}
try{
int[] mat ={-2,0};
methods.callMethod("mat_std","IncMaterialsSave",mat,game);
}catch(System.Reflection.TargetInvocationException){
return 0;
}
return 1;
}
case "SwordFighter":{
if(game.materials.Food >= 2 && game.materials.Money >= 2){
return 1;
}else{return 0;}
try{
int[] mat ={-2,-2};
methods.callMethod("mat_std","IncMaterialsSave",mat,game);
}catch(System.Reflection.TargetInvocationException){
return 0;
}
return 1;
}
case "BowFighter":{
if(game.materials.Food >= 2 && game.materials.Money >= 4){
return 1;
}else{return 0;}
try{
int[] mat ={-2,-4};
methods.callMethod("mat_std","IncMaterialsSave",mat,game);
}catch(System.Reflection.TargetInvocationException){
return 0;
}
return 1;
}
default: return -1;
}
}

private void subtractMaterials(string entityClass){
switch(entityClass){
case "Worker":{
game.materials.Food-= 2;
break;
}
case "SwordFighter":{
game.materials.Food -= 2;
game.materials.Money -= 2;
break;
}
case "BowFighter":{
game.materials.Food-= 2;
game.materials.Money -= 4;
break;
}
default: return;
}
}


// function that spawns an entity, can be called by player
public void spawnEntity(string input,TIM.main game){
string[] inp = input.Split(",");
Expand All @@ -82,7 +74,7 @@ public void spawnEntity(string input,TIM.main game){
functionProperties entity=new functionProperties(entityClass);
switch(checkMaterials(entityClass)){
case 0:{
Console.WriteLine("Not enough resources");
Console.WriteLine("Could not create entity.");
return;
}case -1:{
Console.WriteLine("{0} can not be created here.", entityClass);
Expand All @@ -93,7 +85,7 @@ public void spawnEntity(string input,TIM.main game){
if(entity.fType.GetMethod("autoSetup") is not null){
entity.fType.GetMethod("autoSetup")!.Invoke(entity.fObject, new object[]{this.position,game});
game.entities.Add(name,entity);
subtractMaterials(entityClass);
game.sys.displayMap(game);
}
}catch (ArgumentException){
Console.WriteLine("INF: Entity '{0}' already exists.",name);
Expand Down
6 changes: 3 additions & 3 deletions src/EntityManagement/Entities/Ore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ public class Ore{
public int mapColor{get;} = 15;
public bool isDestroyed = false;
public Position position{get;set;} = null!;
public int money{get;} = 2;
public int[] mat ={0,2};

public int durability{get;set;} = 3; // number of hits until destroyed

public void getHit(int damage){
durability -= damage;
if(durability<=0){
isDestroyed = true;
isDestroyed = true;
}
}

public void step(TIM.main game){
if(isDestroyed){
game.materials.Money += money;
methods.callMethod("mat_std","IncMaterials",mat,game);
throw new NotSupportedException("Ore was destroyed");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/EntityManagement/Entities/Wildlife/AbstractWildlife.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public abstract class Wildlife: Creature{
protected Position Spawnpoint = null!;
protected abstract int territoryRange{get;} // radius of territory (around spawnpoint)

public abstract int food {get;}
public abstract int[] mat {get;}

public override void autoSetup(Position pos, TIM.main game){
this.game = game;
Expand All @@ -19,7 +19,7 @@ public override void step(TIM.main game)
initIdleMovement(game);
}
if(isDead){
game.materials.Food += food;
methods.callMethod("mat_std","IncMaterials",mat,game);
}
base.step(game);
}
Expand Down
Loading
Loading