[SOLVED] Assignment 2 IS415/615

35.00 $

Category: Tags: , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment-2-7ffcvh.zip (201.8 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

Assignment 2:

File Input/Output and Functions

In this assignment, you will write a small game called traveller.py. The purpose of  this game is to travel along a path.

a.  The player starts at position 1 and needs to move to position 10. The current  position on the path must be stored as csv data in a file called road. Think of  each position on the path as being between the commas of the csv file. The player  will be represented in this file as an X.

b.  The player starts with 100 health, which must be stored in a file called health.  c.  [IS 615 only] The player starts with a potion, which must be stored in a file called

inventory.

Your program will need to take dynamic user input using the input() function. Each  time a user provides an input, this is considered a single turn. The user can provide one of  three valid inputs: r for roll the dice, p for consume potion, and q to quit.

When the dice is rolled, 1 of 6 outcomes will occur:

1.  Take 10 damage  2.  Take a step backwards  3.  Pray for salvation and roll a d10 to be saved. If the roll is equal to 7, send the

player to the end of the path. Otherwise do nothing.

4.  Take 40 damage  5.  [IS 615 only] Double your next movement (forward or back). [IS 415] Do

nothing.

6.  Take a step forward

[IS 615 only] When the potion is selected, restore up to 70 health (100 is full health), and  the potion is now empty and cannot be reused.

You must not maintain any information in any variables between turns. Everything that  you need to remember must be stored in the files: road, health and inventory.

You will need to write many functions to create this game. Each action should be stored  in a function. For example, getting the current position on the road should be performed  by a function that returns a list that contains the information stored in the road file.

The current health and current position on the road should be shown to the user on every  turn.

The player cannot move beyond the edges of the road, positions 1 and 10. Being at  position 10 is the win condition.

1

Assignment 2

IS 415/615

The outcome of each dice roll should be shown to the user. Below is an example game:

python traveller.py  Your current health is: 100  X| | | | | | | | |  Your journey begins. You are  only at the first position.

What will you do, traveller?  r  You rolled a 1  You took 10 damage  Your current health is: 90  X| | | | | | | | |

What will you do, traveller?  r  You rolled a 1  You took 10 damage  Your current health is: 80  X| | | | | | | | |

What will you do, traveller?  r  You rolled a 5  Double your next movement  Your current health is: 80  XX| | | | | | | | |

What will you do, traveller?  r  You rolled a 6  You moved forward  Your current health is: 80   | |X| | | | | | |

What will you do, traveller?  r  You rolled a 3  Nobody heard your prayers  Your current health is: 80   | |X| | | | | | |

What will you do, traveller?  r  You rolled a 2  You moved back  Your current health is: 80   |X| | | | | | | |

What will you do, traveller?  r  You rolled a 1  You took 10 damage  Your current health is: 70   |X| | | | | | | |

What will you do, traveller?  r  You rolled a 5  Double your next movement  Your current health is: 70   |XX| | | | | | | |

What will you do, traveller?  r  You rolled a 1  You took 10 damage  Your current health is: 60   |XX| | | | | | | |

What will you do, traveller?  r  You rolled a 4  You took 40 damage  Your current health is: 20   |XX| | | | | | | |

What will you do, traveller?  p  You consumed your potion  Your current health is: 90   |XX| | | | | | | |

What will you do, traveller?  r  You rolled a 6  You moved forward  Your current health is: 90   | | |X| | | | | |

What will you do, traveller?  r  You rolled a 6

You moved forward  Your current health is: 90   | | | |X| | | | |

What will you do, traveller?  r  You rolled a 5  Double your next movement  Your current health is: 90   | | | |XX| | | | |

What will you do, traveller?  r  You rolled a 5  Double your next movement  Your current health is: 90   | | | |XXXX| | | | |

What will you do, traveller?  r  You rolled a 3  Nobody heard your prayers  Your current health is: 90   | | | |XXXX| | | | |

What will you do, traveller?  r  You rolled a 6  You moved forward  Your current health is: 90   | | | | | | | |X|

What will you do, traveller?  r  You rolled a 1  You took 10 damage  Your current health is: 80   | | | | | | | |X|

What will you do, traveller?  r  You rolled a 6  You moved forward  You made it to the end of the  road. Well done. You win!

2

Assignment 2

IS 415/615

If the player inputs something other than an r, p or q, print out the possible inputs and  wait for another user input.

If the player rolls a 3 and then subsequently rolls a 7, they are moved to position 10 and  win:

The potion can only be consumed once:

3

Assignment 2

IS 415/615

If the player runs out of health, they die and the game is over:

Both IS 415 and IS 615 students will submit just the traveller.py file. The contents  of the file for IS 615 students will be more complex to handle the additional game  mechanics.

4

 

  • Assignment-2-7ffcvh.zip