Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp1;
- using System.Text;
- public class Task19
- {
- public void Run()
- {
- Console.InputEncoding = Encoding.Unicode;
- Console.OutputEncoding = Encoding.Unicode;
- int bossAttackPower = 66;
- int bossMaxHealth = 600;
- int playerMaxHealth = 400;
- string shadowSpiritSummonSpellName = "Shadow Spirit Summon";
- int shadowSpiritSummonSpellPower = 50;
- string fireDogsSummonSpellName = "Fire Dogs Summon";
- int fireDogsSummonSpellPower = 90;
- string dimensionalRiftJumpSpellName = "Dimensional Rift Jump";
- int dimensionalRiftJumpSpellPower = 250;
- int dimensionalRiftJumpSpellHealthBound = 50;
- string reflectShieldSpellName = "Reflect Shield";
- int reflectShieldSpellPower = 25;
- int reflectShieldSpellDuration = 3;
- int reflectShieldSpellRemainedTurns = 0;
- int bossHealth = bossMaxHealth;
- int playerHealth = playerMaxHealth;
- string previousSpellName = string.Empty;
- bool canExit = false;
- while ( canExit == false )
- {
- bool canUseShadowSpiritSummonSpell = true;
- bool canUseFireDogsSummonSpell = string.Equals( previousSpellName, shadowSpiritSummonSpellName );
- bool canUseDimensionalRiftJumpSpell = playerHealth <= dimensionalRiftJumpSpellHealthBound;
- bool canUseReflectShieldSpell = reflectShieldSpellRemainedTurns == 0;
- string spellsList = "Select spell (type name for use): \n";
- if( canUseShadowSpiritSummonSpell )
- spellsList = $"{spellsList}# {shadowSpiritSummonSpellName} \n";
- if( canUseFireDogsSummonSpell )
- spellsList = $"{spellsList}# {fireDogsSummonSpellName} \n";
- if( canUseDimensionalRiftJumpSpell )
- spellsList = $"{spellsList}# {dimensionalRiftJumpSpellName} \n";
- if( canUseReflectShieldSpell )
- spellsList = $"{spellsList}# {reflectShieldSpellName} \n";
- Console.WriteLine(spellsList);
- string selectedSpellName = string.Empty;
- bool isSelectedSpellProperly = false;
- while ( isSelectedSpellProperly == false )
- {
- selectedSpellName = Console.ReadLine();
- isSelectedSpellProperly = string.Equals( selectedSpellName, shadowSpiritSummonSpellName ) && canUseShadowSpiritSummonSpell;
- isSelectedSpellProperly |= string.Equals( selectedSpellName, fireDogsSummonSpellName ) && canUseFireDogsSummonSpell;
- isSelectedSpellProperly |= string.Equals( selectedSpellName, dimensionalRiftJumpSpellName ) && canUseDimensionalRiftJumpSpell;
- isSelectedSpellProperly |= string.Equals( selectedSpellName, reflectShieldSpellName ) && canUseReflectShieldSpell;
- if(isSelectedSpellProperly == false)
- Console.WriteLine("Entered invalid spell, try again:");
- }
- if ( string.Equals( selectedSpellName, shadowSpiritSummonSpellName ) )
- {
- bossHealth -= shadowSpiritSummonSpellPower;
- Console.WriteLine( $"Player deal damage {shadowSpiritSummonSpellPower}, boss health is {bossHealth} now" );
- }
- if ( string.Equals( selectedSpellName, fireDogsSummonSpellName ) )
- {
- bossHealth -= fireDogsSummonSpellPower;
- Console.WriteLine( $"Player deal damage {fireDogsSummonSpellPower}, boss health is {bossHealth} now" );
- }
- if ( string.Equals( selectedSpellName, dimensionalRiftJumpSpellName ) )
- {
- playerHealth += dimensionalRiftJumpSpellPower;
- Console.WriteLine( $"Player restore {dimensionalRiftJumpSpellPower} hitpoints, player health is {playerHealth} now" );
- }
- if ( string.Equals( selectedSpellName, reflectShieldSpellName ) )
- {
- reflectShieldSpellRemainedTurns = reflectShieldSpellDuration;
- Console.WriteLine( $"Reflect shield has been activated on {reflectShieldSpellDuration} turns" );
- }
- bool isBossDead = bossHealth <= 0;
- previousSpellName = selectedSpellName;
- if ( isBossDead == false )
- {
- playerHealth -= bossAttackPower;
- Console.WriteLine( $"Boss deal damage {bossAttackPower}, player health is {playerHealth} now" );
- if ( reflectShieldSpellRemainedTurns > 0 )
- {
- bossHealth -= reflectShieldSpellPower;
- reflectShieldSpellRemainedTurns--;
- Console.WriteLine( $"Reflect shield deal damage {reflectShieldSpellPower}, " +
- $"remained {reflectShieldSpellRemainedTurns} turns, boss health is {bossHealth} now" );
- }
- }
- else
- {
- Console.WriteLine("Boss is dead. Player win.");
- }
- bool isPlayerDead = playerHealth <= 0;
- if ( isPlayerDead )
- {
- Console.WriteLine( "Player is dead. Player lose." );
- }
- Console.WriteLine();
- canExit = isPlayerDead || isBossDead;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement