Created
August 17, 2012 18:36
-
-
Save astagi/3381423 to your computer and use it in GitHub Desktop.
PulcinoPyo: Python script for generating "Pulcino Pio" style (??) songs!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: latin-1 -*- | |
# PulcinoPyo: generate a "Pulcino Pio" style (??) song! | |
# Author: Andrea Stagi on vacation <[email protected]> | |
# License: c'mon default header, don't be silly :D | |
#Our type Animal | |
class Animal: | |
def __init__(self, name, sound, art_d, art_i): | |
self.name = name | |
self.sound = sound | |
self.art_d = art_d | |
self.art_i = art_i | |
#Set all the animals you want with our hero on the first position! | |
animals = [Animal( "pulcino", "pio", "il", "un" ), | |
Animal( "cane", "baubau", "il", "un" ), | |
Animal( "gatto", "miao", "il", "un" ), | |
Animal( "gallo", "chicchirichì", "il", "un" ), | |
Animal( "mucca", "muuu", "la", "una" ), | |
Animal( "trattore", "wroom", "il", "un" ),] | |
#Let's start singing | |
current = 1 | |
anche = "" | |
n_animals = len( animals ) | |
#The title | |
print "\n%s %s %s\n" % ( animals[0].art_d.capitalize(), animals[0].name, animals[0].sound ) | |
for i in range( n_animals ): | |
print "" | |
#Who is new on the radio?? Let's see.. | |
for j in range( 2 ): | |
if current != 1: | |
anche = " anche" | |
print "In radio c'é%s %s %s" % ( anche, animals[i].art_i, animals[i].name ) | |
#Uhm I don't remember who's actually on the radio, damn! | |
for k in reversed(range( current )): | |
print "e %s %s %s" % (animals[k].art_d, animals[k].name, animals[k].sound ) | |
#Pulcino Pio, it's your moment!! | |
pulcino_sound_range = (3 - (( current + 1 ) % 2)) | |
for j in range( pulcino_sound_range ): | |
if i == (n_animals - 1) and j == pulcino_sound_range - 1: | |
animals[0].sound = "oh oh!" | |
print "e %s %s %s" % (animals[0].art_d, animals[0].name, animals[0].sound ) | |
current += 1 | |
print "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment