Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Jan 24, 2021
0 parents commit 409c194
Show file tree
Hide file tree
Showing 16,290 changed files with 325,847 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
26 changes: 26 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
permalink: /404.html
layout: default
---

<style type="text/css" media="screen">
.container {
margin: 10px auto;
max-width: 600px;
text-align: center;
}
h1 {
margin: 30px 0;
font-size: 4em;
line-height: 1;
letter-spacing: -1px;
}
</style>

<div class="container">
<h1>Wrong link!</h1>

<p><strong>Page not found :(</strong></p>
<p>Back to homepage game!</p>
<a href="{{ '/' | relative_url }}">click here!</a>
</div>
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source "https://rubygems.org"

gem "jekyll", "~> 4.1.1"

platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", "~> 1.2"
gem "tzinfo-data"
end

group :jekyll_plugins do
gem "jekyll-seo-tag"
end

gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
73 changes: 73 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
colorator (1.1.0)
concurrent-ruby (1.1.8)
em-websocket (0.5.2)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.2.7)
ffi (1.13.1)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
jekyll (4.1.1)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (~> 2.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (~> 0.4.0)
pathutil (~> 0.9)
rouge (~> 3.0)
safe_yaml (~> 1.0)
terminal-table (~> 1.8)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.7.1)
jekyll (>= 3.8, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.3.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.3.3)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.6)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.4)
rouge (3.25.0)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.7.0)

PLATFORMS
ruby

DEPENDENCIES
jekyll (~> 4.1.1)
jekyll-seo-tag
tzinfo (~> 1.2)
tzinfo-data
wdm (~> 0.1.1)

BUNDLED WITH
2.1.4
17 changes: 17 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: Tic Tac Toe

baseurl: "/pure-html-tic-tac-toe"

plugins:
- jekyll-seo-tag

exclude:
- .sass-cache/
- .jekyll-cache/
- gemfiles/
- Gemfile
- Gemfile.lock
- generator.py
- template
- README.md
- LICENSE
9 changes: 9 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<link rel="stylesheet" href="{{ 'styles.css' | relative_url }}">
{% seo %}
</head>
<body>
{{ content }}
</body>
</html>
10 changes: 10 additions & 0 deletions _layouts/player_o.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<link rel="stylesheet" href="{{ 'styles.css' | relative_url }}">
{% seo %}
</head>
<body>
Player: O
{{ content }}
</body>
</html>
10 changes: 10 additions & 0 deletions _layouts/player_x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<link rel="stylesheet" href="{{ 'styles.css' | relative_url }}">
{% seo %}
</head>
<body>
Player: X
{{ content }}
</body>
</html>
10 changes: 10 additions & 0 deletions _layouts/winner_o.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<link rel="stylesheet" href="{{ 'styles.css' | relative_url }}">
{% seo %}
</head>
<body>
Winner is player: O
{{ content }}
</body>
</html>
10 changes: 10 additions & 0 deletions _layouts/winner_x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<link rel="stylesheet" href="{{ 'styles.css' | relative_url }}">
{% seo %}
</head>
<body>
Winner is player: X
{{ content }}
</body>
</html>
88 changes: 88 additions & 0 deletions generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import sys

with open('template') as file:
template = file.read()

total_count = 0
total_win_x = 0
total_win_y = 0

class Stroke:
def __init__ (self, url = ''):
# Global variables
global total_count
global total_win_x
global total_win_y
global template

# Construct
self.table = ['&nbsp;'] * 9
self.links = ['false'] * 9
total_count += 1

# Analysis self url & Make Table
for index in range (0, len(url), 2):
self.table[int(url[index])] = url[index + 1]

# State detect
if self.is_winner():
self.winner = True
self.player = url[-1]
self.layout = 'winner_' + self.player

else:
self.winner = False
self.player = 'o' if len(url) != 0 and url[-1] == 'x' else 'x'
self.layout = 'player_' + self.player

# Make others url's
for index in range(9):
if self.table[index] == '&nbsp;' and not self.winner:
self.links[index] = ''.join([(str(i) + self.table[i]) for i in range(9) if self.table[i] != '&nbsp;'])
self.links[index] += str(index) + self.player

# Block new stroke
if self.winner:
self.links = ['false'] * 9
total_win_x += int(self.player == 'x')
total_win_y += int(self.player == 'o')

# Make webpage file
url = 'index' if url == '' else url
sys.stderr.write(f"[{total_count}] writing file {url}.html\n")
with open(f"./multiplayer/{url}.html", "w") as file:
html = template.format(layout = self.layout, links = self.links, table = self.table)
html = html.replace('href="false"', '')
html = html.replace('href="', 'href="{{ \'multiplayer/')
html = html.replace('">&', '.html\' | relative_url }}">&')
html = html.replace('">x', '.html\' | relative_url }}">x')
html = html.replace('">o', '.html\' | relative_url }}">o')
file.write(html)

# Next
[Stroke(self.links[i]) for i in range(9) if self.links[i] != 'false']

def is_winner(self):
winner = False
# Horizontal detect
winner |= self.table[0] == self.table[1] and self.table[1] == self.table[2] and self.table[2] != '&nbsp;'
winner |= self.table[3] == self.table[4] and self.table[4] == self.table[5] and self.table[5] != '&nbsp;'
winner |= self.table[6] == self.table[7] and self.table[7] == self.table[8] and self.table[8] != '&nbsp;'
# Diagonal detect
winner |= self.table[0] == self.table[4] and self.table[4] == self.table[8] and self.table[8] != '&nbsp;'
winner |= self.table[3] == self.table[4] and self.table[4] == self.table[6] and self.table[6] != '&nbsp;'
# Verical detect
winner |= self.table[0] == self.table[3] and self.table[3] == self.table[6] and self.table[6] != '&nbsp;'
winner |= self.table[1] == self.table[4] and self.table[4] == self.table[7] and self.table[7] != '&nbsp;'
winner |= self.table[2] == self.table[5] and self.table[5] == self.table[8] and self.table[8] != '&nbsp;'
return winner

# bootstrap
Stroke()

# logs
sys.stderr.write(f"""[!] Done.
> Files: {total_count}
> Player X Winners: {total_win_x}
> Player Y Winners: {total_win_y}
""")
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: default
description: >-
Game Tic Tac Toe building only with HTML5
using half a million of static web page files.
---

<a href="{{ '/multiplayer' | relative_url }}">2 Players</a>
20 changes: 20 additions & 0 deletions multiplayer/0o1o2x3o4o5x6x7x8x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: winner_x
---
<table>
<tr>
<td><a >o</a></td>
<td class="border" id="foo"><a >o</a></td>
<td><a >x</a></td>
</tr>
<tr>
<td class="border" id="bar"><a >o</a></td>
<td class="border"><a >o</a></td>
<td class="border" id="baz"><a >x</a></td>
</tr>
<tr>
<td><a >x</a></td>
<td class="border" id="z"><a >x</a></td>
<td><a >x</a></td>
</tr>
</table>
20 changes: 20 additions & 0 deletions multiplayer/0o1o2x3o4x5o6x7x8x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: winner_x
---
<table>
<tr>
<td><a >o</a></td>
<td class="border" id="foo"><a >o</a></td>
<td><a >x</a></td>
</tr>
<tr>
<td class="border" id="bar"><a >o</a></td>
<td class="border"><a >x</a></td>
<td class="border" id="baz"><a >o</a></td>
</tr>
<tr>
<td><a >x</a></td>
<td class="border" id="z"><a >x</a></td>
<td><a >x</a></td>
</tr>
</table>
20 changes: 20 additions & 0 deletions multiplayer/0o1o2x3o4x5o6x8x7x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: winner_x
---
<table>
<tr>
<td><a >o</a></td>
<td class="border" id="foo"><a >o</a></td>
<td><a >x</a></td>
</tr>
<tr>
<td class="border" id="bar"><a >o</a></td>
<td class="border"><a >x</a></td>
<td class="border" id="baz"><a >o</a></td>
</tr>
<tr>
<td><a >x</a></td>
<td class="border" id="z"><a >x</a></td>
<td><a >x</a></td>
</tr>
</table>
20 changes: 20 additions & 0 deletions multiplayer/0o1o2x3o4x5o7x8x6x.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: winner_x
---
<table>
<tr>
<td><a >o</a></td>
<td class="border" id="foo"><a >o</a></td>
<td><a >x</a></td>
</tr>
<tr>
<td class="border" id="bar"><a >o</a></td>
<td class="border"><a >x</a></td>
<td class="border" id="baz"><a >o</a></td>
</tr>
<tr>
<td><a >x</a></td>
<td class="border" id="z"><a >x</a></td>
<td><a >x</a></td>
</tr>
</table>
Loading

0 comments on commit 409c194

Please sign in to comment.