Skip to content

Instantly share code, notes, and snippets.

class Screen:
def __init__(self, size):
self.size = size
# create an array with `size` lines of `size` dots
# multiplying a string like `"hello world! " * 20`
# then multiplying the array
self.screen = ['.' * size] * size
def __str__(self):
return str.join("\n", self.screen)
import time
import sys
pet = {
"name": input("Name your pet!\n>"),
"hunger": 0,
"happiness": 100,
}
TYPES_IDX = ["normal", "fire", "water", "electric", "grass", "ice", "fighting",
"poison", "ground", "flying", "psychic", "bug", "rock", "ghost", "dragon",
"dark", "steel", "fairy", ]
EFFECTS = [
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.5, 0, 1, 1, 0.5, 1, ],
[ 1, 0.5, 0.5, 1, 2, 2, 1, 1, 1, 1, 1, 2, 0.5, 1, 0.5, 1, 2, 1, ],
[ 1, 2, 0.5, 1, 0.5, 1, 1, 1, 2, 1, 1, 1, 2, 1, 0.5, 1, 1, 1, ],
[ 1, 1, 2, 0.5, 0.5, 1, 1, 1, 0, 2, 1, 1, 1, 1, 0.5, 1, 1, 1, ],
[ 1, 0.5, 2, 1, 0.5, 1, 1, 0.5, 2, 0.5, 1, 0.5, 2, 1, 0.5, 1, 0.5, 1, ],
[ 1, 0.5, 0.5, 1, 2, 0.5, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 0.5, 1, ],
import sys
import time
import random
# this function will prompt the user every choice in array `choices`
# they must select with a number. returns the index they selected
def multiple_choice(choices):
highest_choice = len(choices)
for i, choice in enumerate(choices):
print(i + 1, choice)
import random
import time
player_health = 100
player_experience = 0
player_name = input("Welcome to the land of the Ylsides, what is your name? ")
def start_fight(enemy_name, enemy_health, enemy_damage, experience_awarded):
# Global variables to be modified.