Skip to content

Commit

Permalink
v0.16
Browse files Browse the repository at this point in the history
- Changed the scenario's file extension to .html from .story
- Changes to adopt html parsing, similar to xml
  • Loading branch information
U-C-S committed Oct 29, 2020
1 parent 6351558 commit 3456bf5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 95 deletions.
33 changes: 23 additions & 10 deletions Something/Game.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -27,17 +28,27 @@ public Game(XDocument XMLfile)
{
InitializeComponent();
SourceFileXML = XMLfile;
currentElem = SourceFileXML.Root.Element("story").Element("START");
ajna("START");
Renderer();
}

void ajna(string source)
{
IEnumerable<XElement> a = SourceFileXML.Root.Element("body").Elements("div");
foreach (XElement e in a)
{
if(e.Attribute("id").Value == source)
{
currentElem = e;
}
}
}
void Renderer()
{
try
{
BrContext.Text = currentElem.Element("conseq").Value.ToString();
path1.Content = currentElem.Element("choice1").Element("btn").Value.ToString();
path2.Content = currentElem.Element("choice2").Element("btn").Value.ToString();
BrContext.Text = currentElem.Element("p").Value.ToString();
path1.Content = currentElem.Elements("a").First().Value.ToString();
path2.Content = currentElem.Elements("a").Last().Value.ToString();
}
catch (System.NullReferenceException)
{
Expand All @@ -49,18 +60,20 @@ void Renderer()
private void PathClick(object sender, RoutedEventArgs e)
{
string actionElem;
if((string)(sender as Button).Tag == "btn1")
actionElem = currentElem.Element("choice1").Element("action").Value.ToString();

if ((string)(sender as Button).Tag == "btn1")
actionElem = currentElem.Elements("a").First().Attribute("href").Value.ToString();
else
actionElem = currentElem.Element("choice2").Element("action").Value.ToString();
actionElem = currentElem.Elements("a").Last().Attribute("href").Value.ToString();

if(actionElem == "END" || actionElem == null)
actionElem = actionElem.Remove(0,1);
if (actionElem == "END")
{
GameOver();
}
else
{
currentElem = SourceFileXML.Root.Element("story").Element(actionElem);
ajna(actionElem);
Renderer();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Something/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: AssemblyVersion("0.15.0.0")]
[assembly: AssemblyFileVersion("0.15.0.0")]
[assembly: AssemblyVersion("0.16.0.0")]
[assembly: AssemblyFileVersion("0.16.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]
Binary file modified _Output/Something.exe
Binary file not shown.
54 changes: 29 additions & 25 deletions _Output/Trees/Test.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,34 @@
<a href="#content" data-btn="2">choice2 btn context</a>
</div>
<div id="START">
<p>Conseqcuences for the Choices</p>
<a href="#content" data-btn="1">choice1 btn context</a>
<a href="#content" data-btn="2">choice2 btn context</a>
<p>Which color is yellow?</p>
<a href="#a" data-btn="1">light Yellow</a>
<a href="#b" data-btn="2">Pure Red</a>
</div>
<div id="a">
<p>You are right. light yellow is a yellow color. Now, Wanna go to next question?</p>
<a href="#aba" data-btn="1">ok</a>
<a href="#aba" data-btn="2">OK</a>
</div>
<div id="b">
<p>Oh you are wrong and unintelligent. now accept light yellow is yellow</p>
<a href="#aba" data-btn="1">Ok</a>
<a href="#aba" data-btn="2">Fine Ok</a>
</div>
<div id="aba">
<p>Which language is this program written in?</p>
<a href="#abaa" data-btn="1">C#</a>
<a href="#abab" data-btn="2">C++</a>
</div>
<div id="abaa">
<p>Correct. Wanna play this game again?</p>
<a href="#START" data-btn="1">Yeh. why not</a>
<a href="#END" data-btn="2">Get lost</a>
</div>
<div id="abab">
<p>Wrong. This program is in C#</p>
<a href="#END" data-btn="1">this is dumb</a>
<a href="#START" data-btn="2">again</a>
</div>
</body>
</html>


<!--
<div class="main-square">
<div class="title-ucs">
<h1>U C S</h1>
<p>U Chanakya S</p>
</div><hr>
<div class="para-img"><img src="files/UCS/paradox.png" alt="paradox-triangle"></div>
<div class="godown"><button id="down-btn">CheckOut</button></div>
</div>
<div id="content">
<div class="c-row">
<button id="navbtn">The BOcT</button>
</div>
<p><-- A Updated Design to this Site is on Pre-Production</p>
</div>
-->
</html>
54 changes: 0 additions & 54 deletions _Output/Trees/Test2.story

This file was deleted.

8 changes: 4 additions & 4 deletions _Output/Trees/_stories.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
<story1>
<name font="1">Test1</name>
<description>This is still in beta. Why not press the next-button to check whether it's working or not</description>
<filename>Test.xml</filename>
<filename>Test.html</filename>
</story1>
<story2>
<name>Test2: Success</name>
<description>So it's a Success. Welcome to Next-gen</description>
<filename>Test2.story</filename>
<filename>Test.html</filename>
</story2>
<story3>
<name font="2">Death by Mass Killing</name>
<description>You can't kill everyone but you can influence everyone.</description>
<filename>Test.story</filename>
<filename>Test.html</filename>
</story3>
<story4>
<name font="3">Death by Dying</name>
<description>You can do it.</description>
<filename>Test.story</filename>
<filename>Test.html</filename>
</story4>
</root>

0 comments on commit 3456bf5

Please sign in to comment.