#!/usr/local/bin/python
# -*- coding: UTF-8 -*-

import Cookie
import cgi
import cgitb; cgitb.enable()  # for troubleshooting
import Player
import os

thecookie = os.environ.get('HTTP_COOKIE')
C = Cookie.SimpleCookie()
C.load(thecookie)

enemy = C["enemy"].value
me = C["username"].value
bf = C["field"].value
outcome = C["outcome"].value
score1 = 0
for i in open('scores.txt', 'r'):
	if i.startswith(me):
		score1 = i.split(" ")[1]

C1 = Cookie.SimpleCookie()
C1["score"] = score1

print C1	
print "Content-type: text/html"
print


print """
<html>

<head>
<link rel="stylesheet" type="text/css" href="battle.css" media="screen" />
		<title>Battle Time!</title></head>

<body>

  <h3> Results</h3>
  
"""
if outcome == "win":
	print """
	
	<p>YOU WON!!!! HOORAY YOUR PRIZE IS - LIFE</p>


	"""
else:
	print """
	<p>YOU LOST. It's ok, at least your mother will mourn your death (probably).</p>
	"""

print """
	
  <p>Your new rating is <b>%s</b><p>
  
  <form method="post" action="delete.cgi">


	<input type="submit" value= "Back to Lobby"/>
  </form>
  
 """%score1

 
  

