Hello Kitty

From ICO wiki
Revision as of 18:55, 11 June 2012 by Jvarus (talk | contribs) (→‎Veebiteenus)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

LIIKMED

  • Herki Pärn
  • Jaanus Varus
  • Fred Mihkelsoo

Klientrakendus

Uuendatud 11.06.2012!

Viimased versioonid klientrakendusest, veebiteenusest ja andmebaasi backupist on saadavalt siit: http://www.upload.ee/files/2421783/vr2_demo.rar.html

Klientrakendus kujutab endast Kurt Jaegersi poolt XNA platvormile loodud mängu Asteroid Belt Assault porti html5'le. Antud mängu lähtekood ja graafilised/audio komponendid on vabavaraliselt kasutatavad. Mängu hostitakse Asp.Net website'il. Rakendus kasutab skooride haldamiseks oma loodud veebiteenust.

Veebiteenus

Uuendatud 11.06.2012!

Veebiteenuse eesmärgiks on pakkuda võimalust mänguettevõtjatele registreerida nende kasutajaid, mänge ning hallata nende skoore üle veebiteenuse. Veebiteenus on loodud WCF tehnoloogia abil. Andmeid hoitakse MSSQL 2008 r2 andmebaasis. Kasutajate autentimine käib üle andmebaasi (forms authentication). Suhtlus veebiteenuse ja andmebaasi vahel käib üle LINQu. Veebiteenus pakub andmete täielikuks haldamiseks basicHttp endpointi. Andmed on turvatud üle SSL protokolli. Samuti on andmete lugemine võimalik ka üle webHttp endpointi, läbi mille lubatakse teatud funktsioonidele läbi brauseri ligipääsu GET päringuga. Viimaseks endpointiks on juba defaultina ära konfitud mexHttp endpoint, mis annab klientrakendusele ülevaate teenusest ning vaheklasside struktuuri.

Veebiteenuse lähtekood koos andmebaasi backupiga on saadavalt klientrakenduse sektsiooni all.

XML

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<matches xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="game_matches.xsd">  
  <match id="1" type="tdm" duration="00:40:33" created="2002-09-24-17:31">
		<teams>
			<team name="red" victorious="false" score="885">
				<players>
					<player id="1" name="Anissa" score="614" victorious="false" />
					<player id="2" name="Jesus" score="157" victorious="false" />
					<player id="3" name="Erick" score="17" victorious="false" />
					<player id="4" name="Verena" score="97" victorious="false" />
				</players>
			</team>
			<team name="blue" victorious="true" score="2682">
				<players>
					<player id="5" name="Fredric" score="729" victorious="true" />
					<player id="6" name="Lynda" score="573" victorious="true" />
					<player id="7" name="Ingrid" score="958" victorious="true" />
					<player id="8" name="Charmaine" score="422" victorious="true" />
				</players>
			</team>
		</teams>
	</match>
	<match id="2" type="dm" duration="00:31:10" created="2002-09-23-14:10">
		<players>
			<player id="9" name="Rosa" score="24" victorious="false" />
			<player id="10" name="Jolyn" score="85" victorious="true" />
			<player id="11" name="Kristyn" score="61" victorious="false" />
		</players>
	</match>
	<match id="3" type="dm" duration="00:25:50" created="2002-09-24-16:05">
		<players>
			<player id="2" name="Jesus" score="67" victorious="false" />
			<player id="1" name="Anissa" score="106" victorious="true" />
			<player id="6" name="Lynda" score="99" victorious="false" />
		</players>
	</match>
	<match id="4" type="tdm" duration="00:51:19" created="2002-09-25-23:31">
		<teams>
			<team name="red" victorious="true" score="1882">
				<players>
					<player id="1" name="Anissa" score="1005" victorious="true" />
					<player id="2" name="Jesus" score="794" victorious="true" />
					<player id="3" name="Erick" score="81" victorious="true" />
					<player id="4" name="Verena" score="2" victorious="true" />
				</players>
			</team>
			<team name="blue" victorious="false" score="1560">
				<players>
					<player id="5" name="Fredric" score="710" victorious="false" />
					<player id="6" name="Lynda" score="496" victorious="false" />
					<player id="7" name="Ingrid" score="194" victorious="false" />
					<player id="8" name="Charmaine" score="160" victorious="false" />
				</players>
			</team>
		</teams>
	</match>
</matches>

XSD

<?xml version="1.0" encoding="utf-8"?>

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="matches">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="match">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="players">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="player">
                      <xs:complexType>
                        <xs:attribute name="id" type="xs:unsignedInt" use="required" />
                        <xs:attribute name="name" type="xs:string" use="required" />
                        <xs:attribute name="score" type="xs:unsignedInt" use="required" />
                        <xs:attribute name="victorious" type="xs:boolean" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" name="teams">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs="2" maxOccurs="unbounded" name="team">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="players">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="player">
                                  <xs:complexType>
                                    <xs:attribute name="id" type="xs:unsignedInt" use="required" />
                                    <xs:attribute name="name" type="xs:string" use="required" />
                                    <xs:attribute name="score" type="xs:unsignedInt" use="required" />
                                    <xs:attribute name="victorious" type="xs:boolean" use="required" />
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="name" type="xs:string" use="required" />
                        <xs:attribute name="victorious" type="xs:boolean" use="required" />
                        <xs:attribute name="score" type="xs:unsignedInt" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:unsignedInt" use="required" />
            <xs:attribute name="type" type="xs:string" use="required" />
            <xs:attribute name="duration" type="xs:time" use="required" />
            <xs:attribute name="created" type="xs:date" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="utf-8" />
  <xsl:template match="/">
    <xsl:text disable-output-escaping="yes">
      <!DOCTYPE html>
    </xsl:text>
    <html>
      <body>
        <h2>Game matches:</h2>        
          <xsl:for-each select="matches/match">
            <table border="1" style="margin: 10px; float: left;">
            <xsl:choose>
              <xsl:when test="@type = 'tdm'">                                
                  <tr style="background-color: #917A56;">
                    <th>Player</th>
                    <th>Team</th>
                    <th>Score</th>
                    <th>Victorious</th>
                  </tr>
                <xsl:for-each select="teams/team">
                  <xsl:for-each select="players/player">
                    <xsl:choose>
                      <xsl:when test="position() mod 2 = 0">
                        <xsl:text disable-output-escaping="yes">
                        <tr style="background-color: #FEFFC2;">
                      </xsl:text>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:text disable-output-escaping="yes">
                        <tr style="background-color: #B4BA6C;">
                      </xsl:text>
                      </xsl:otherwise>
                    </xsl:choose>
                    <td>
                      <xsl:value-of select="@name" />
                    </td>
                    <td>
                      <xsl:value-of select="../../@name" />
                    </td>
                    <td>
                      <xsl:value-of select="@score" />
                    </td>
                    <td>
                      <xsl:value-of select="@victorious"/>
                    </td>
                    <xsl:text disable-output-escaping="yes">
                      </tr>
                    </xsl:text>
                  </xsl:for-each>                  
                </xsl:for-each>
              </xsl:when>
              <xsl:otherwise>
                <tr style="background-color: #917A56;">
                  <th>Player</th>
                  <th>Score</th>
                  <th>Victorious</th>
                </tr>
                <xsl:for-each select="players/player">
                  <xsl:choose>
                    <xsl:when test="position() mod 2 = 0">
                      <xsl:text disable-output-escaping="yes">
                        <tr style="background-color: #FEFFC2;">
                      </xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:text disable-output-escaping="yes">
                        <tr style="background-color: #B4BA6C;">
                      </xsl:text>
                    </xsl:otherwise>                    
                  </xsl:choose>
                  <td>
                    <xsl:value-of select="@name" />
                  </td>
                  <td>
                    <xsl:value-of select="@score" />
                  </td>
                  <td>
                    <xsl:value-of select="@victorious"/>
                  </td>
                  <xsl:text disable-output-escaping="yes">
                    </tr>
                  </xsl:text>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
            </table>
          </xsl:for-each>       
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>  
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="utf-8" indent="yes" />
  <xsl:template match="/">
    <matches>
      <xsl:for-each select="matches/match">
        <xsl:choose>
          <xsl:when test="@type = 'tdm'">
            <match>
              <xsl:attribute name="id">
                <xsl:value-of select="@id" />
              </xsl:attribute>
              <xsl:attribute name="type">
                <xsl:value-of select="@type" />
              </xsl:attribute>
              <xsl:attribute name="duration">
                <xsl:value-of select="@duration" />
              </xsl:attribute>
              <xsl:attribute name="created">
                <xsl:value-of select="@created" />
              </xsl:attribute>
              <teams>
                <xsl:for-each select="teams/team">
                  <team>
                    <xsl:attribute name="name">
                      <xsl:value-of select="@name" />
                    </xsl:attribute>
                    <xsl:attribute name="victorious">
                      <xsl:value-of select="@victorious" />
                    </xsl:attribute>
                    <xsl:attribute name="score">
                      <xsl:value-of select="@score" />
                    </xsl:attribute>
                    <players>
                      <xsl:for-each select="players/player">
                        <player>
                          <xsl:attribute name="id">
                            <xsl:value-of select="@id" />
                          </xsl:attribute>
                          <xsl:attribute name="name">
                            <xsl:value-of select="@name" />
                          </xsl:attribute>
                          <xsl:attribute name="victorious">
                            <xsl:value-of select="@victorious" />
                          </xsl:attribute>
                          <xsl:attribute name="score">
                            <xsl:value-of select="@score" />
                          </xsl:attribute>
                        </player>
                      </xsl:for-each><!-- FOREACH PLAYER ENDS HERE -->
                    </players>
                  </team>
                </xsl:for-each><!-- FOREACH TEAM ENDS HERE -->
              </teams>                                  
            </match>
          </xsl:when>
        </xsl:choose>
      </xsl:for-each><!-- FOREACH MATCH ENDS HERE -->   
    </matches>
  </xsl:template>
</xsl:stylesheet>