// DictionaryEtcetera.swift
// Playground - noun: a place where people can play
import UIKit

var teams:[String] = ["Adelaide", "Brisbane Lions", "Carlton", "Collingwood", "Essendon", "Fremantle", "Geelong Cats", "Gold Coast", "GWS Giants", "Hawthorn", "Melbourne", "North Melbourne", "Port Adelaide", "Richmond", "St Kilda", "Sydney Swans", "West Coast", "Western Bulldogs"]
var top8:[String] = ["Hawthorn", "Fremantle", "Sydney Swans", "Geelong Cats", "Port Adelaide", "West Coast", "Richmond", "Essendon"]
var bot10:[String] = ["North Melbourne", "Gold Coast", "Collingwood", "Adelaide", "Western Bulldogs", "Carlton", "Brisbane Lions", "GWS Giants", "Melbourne", "St Kilda"]
var tophomeawaypoints:[String: Int] = [top8[0]:76, top8[1]:72, top8[2]:72, top8[3]:68, top8[4]:52, top8[5]:48, top8[6]:48, top8[7]:44]
var bothomeawaypoints:[String: Int] = [bot10[0]:44, bot10[1]:44, bot10[2]:44, bot10[3]:40, bot10[4]:36, bot10[5]:32, bot10[6]:20, bot10[7]:20, bot10[8]:16, bot10[9]:12]
var ateam:String
var linedrawn:Bool = false
var num:Int = top8.count, position:Int, points:Int

if (tophomeawaypoints["Collingwood"] != nil) {
    points = tophomeawaypoints["Collingwood"]!
    println("Collingwood got wonderful \(points) in 2014 home and away season")
} else {
    points = bothomeawaypoints["Collingwood"]!
    println("Collingwood got not so wonderful \(points) in 2014 home and away season")
}
println("----------------------------------------")

for position in 1...teams.count {
  for ateam in teams {
    if (position <= num && ateam == top8[position - 1]) {
        points = tophomeawaypoints[ateam]!
        println(top8[position - 1] + " ended home and away with \(points) points")
    } else if (position > num && ateam == bot10[position - 1 - num]) {
        if (!linedrawn) {
            println("----------------------------------------")
            linedrawn = true
        }
        points = bothomeawaypoints[ateam]!
        println(bot10[position - 1 - num] + " ended home and away with \(points) points")
    }
  }
}


