Help with a text adventure game in c#

Join Discord

JoeDunn

LOMCN Veteran
Veteran
Jun 16, 2009
1,043
123
149
so ive got my game for my next assignment pretty much done apart from the last boss fight, i know it should probably be simple but i am struggling to link buying a boss key for 10 normal keys and then breaking out of a random encounter loop to start the boss fight. Would any one be willing to take a look and offer some help in getting it working please.
 

JoeDunn

LOMCN Veteran
Veteran
Jun 16, 2009
1,043
123
149
Have you tried chat gpt?
no ive tried to stay away this long. i hear good things but the risk of me cheating using it to much and not learning puts me off using it because i know ill abuse it like a gta cheat code lol.
 

Demonolith

Caswell
Golden Oldie
Oct 7, 2006
542
62
135
Swansea
no ive tried to stay away this long. i hear good things but the risk of me cheating using it to much and not learning puts me off using it because i know ill abuse it like a gta cheat code lol.
Ahh thats a good point, but its basically what you are asking here :p You can still learn from it.
 

zedina

Mir3 Dev
Legendary
Dec 22, 2005
3,168
1
1,017
340
Do another class for monster like MonsterObject where you got various methods which can be triggered from PlayerObject (main class).
 
  • Like
Reactions: Omnibus

zedina

Mir3 Dev
Legendary
Dec 22, 2005
3,168
1
1,017
340
this isn't Mir related? as far as I can see it isn't anyways
What it has to do with Mir?

Do you think objects / class inheritance exists only on mir? :oops:

He can simply do a method inside player of rolling the key

if ((Random.Next(1,10) => 5)
{
MonsterObject.BossSpawn();
}
 

Valhalla

Nexus Mir Developer
Veteran
Sep 7, 2012
1,951
3
451
150
127.0.0.1
What it has to do with Mir?

Do you think objects / class inheritance exists only on mir? :oops:

He can simply do a method inside player of rolling the key

if ((Random.Next(1,10) => 5)
{
MonsterObject.BossSpawn();
}
I understand that, I thought that you thought this was in a Mir section instead of Tech Support. 😂 With MonsterObject and PlayerObject (Your response looked very Mir related, when this thread isn't).
 

JoeDunn

LOMCN Veteran
Veteran
Jun 16, 2009
1,043
123
149
I understand that, I thought that you thought this was in a Mir section instead of Tech Support. 😂 With MonsterObject and PlayerObject (Your response looked very Mir related, when this thread isn't).
What it has to do with Mir?

Do you think objects / class inheritance exists only on mir? :oops:

He can simply do a method inside player of rolling the key

if ((Random.Next(1,10) => 5)
{
MonsterObject.BossSpawn();
}
i understood what you was saying. so i don't know if you meant it like this but this is how i spaghettied it to work

shop code.
else if (item == "unlock")
p.bosskey++;
Encounters.BossEncounter();


in to
public static void BossEncounter()
{
switch (rand.Next(0, 3))
{
case 0:
BossChat();
break;
case 1:
BossChat();
break;
}

which then starts

public static void BossChat()
{
Program.Print("As you enter the grand hall you notice a shadow growing larger in the depths of the tomb as the door slams shut behind you ");
Program.Print("A Howling Scream is unleashed 'THIS IS MY BIRTH RIGHT' as the shadow dashes foward you quickly raise your weapon to block the attack.");
Program.Print("'You all thought i was dead. i been waiting hinding plotting my return when the power is needed the most and none of you shall stop me' screamed Dr Holt");
Console.WriteLine("");
Console.ReadKey();
BossCombat(false, "", 0,0);


which finally calls in my boss fight.

cheers zed even if it wasn't what you was saying to do it still helped me get it working
 
  • Like
Reactions: zedina

zedina

Mir3 Dev
Legendary
Dec 22, 2005
3,168
1
1,017
340
i understood what you was saying. so i don't know if you meant it like this but this is how i spaghettied it to work

shop code.
else if (item == "unlock")
p.bosskey++;
Encounters.BossEncounter();


in to
public static void BossEncounter()
{
switch (rand.Next(0, 3))
{
case 0:
BossChat();
break;
case 1:
BossChat();
break;
}

which then starts

public static void BossChat()
{
Program.Print("As you enter the grand hall you notice a shadow growing larger in the depths of the tomb as the door slams shut behind you ");
Program.Print("A Howling Scream is unleashed 'THIS IS MY BIRTH RIGHT' as the shadow dashes foward you quickly raise your weapon to block the attack.");
Program.Print("'You all thought i was dead. i been waiting hinding plotting my return when the power is needed the most and none of you shall stop me' screamed Dr Holt");
Console.WriteLine("");
Console.ReadKey();
BossCombat(false, "", 0,0);


which finally calls in my boss fight.

cheers zed even if it wasn't what you was saying to do it still helped me get it working
yeah, looks like you have all code in a class which can be difficult sometime to manage all bits but yeah you did it fine
but if you want to break 10 keys in a chance for a big boss key, then your code when you roll that should have something like this


if random chance is success
take 10keys
give 1bosskey

and through that you can code a different method where checks the boss key and calls BossChat()
 

JoeDunn

LOMCN Veteran
Veteran
Jun 16, 2009
1,043
123
149
yeah, looks like you have all code in a class which can be difficult sometime to manage all bits but yeah you did it fine
but if you want to break 10 keys in a chance for a big boss key, then your code when you roll that should have something like this


if random chance is success
take 10keys
give 1bosskey

and through that you can code a different method where checks the boss key and calls BossChat()
its just a one way gate so i have it just to check for then 10 keys or return the default. there probably quite a few bugs but its stable enough for today . heres the game if you want to see its not balanced in anyway gold and health just for testing ect


its not great but I'm proud of my first real bit of coding :)