commit 030195bfb283e2ec82a0157885166548322a2da9 Author: bluesaxman Date: Tue Jun 9 13:48:19 2020 -0600 Initial commit for deckard and company diff --git a/API/decard.pl b/API/decard.pl new file mode 100644 index 0000000..fd752d6 --- /dev/null +++ b/API/decard.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use JSON; +# use database engine + +sub get_request_info { + my $clientIP = ($ENV{"REMOTE_ADDR"} or "0.0.0.0"); + my $proto = ($ENV{"REQUEST_SCHEME"} or "http"); + my $get_query = (split(/\?/,($ENV{"QUERY_STRING"} or "")))[0]; + my $post_query = ""; + if ( $ENV{"CONTENT_LENGTH"} ) { read( , $post_query, $ENV{"CONTENT_LENGTH"}); } + my $referrer = ($ENV{"HTTP_REFERER"} or ""); + return ($proto,$clientIP,$get_query,$post_query,$referrer); +} + +sub http_status { + my ($status,$content,$target) = @_; + my $header = ""; + $header .= "status: ".$status."\r\n"; + $header .= "Location: ".$target."\r\n" if $target; + $header .= "Content-Type: ".$content."\r\n" if $content; + $header .= "\r\n"; + return $header; +} + +sub html_tag { + if ($_[1]) { return "<".($_[0] or "div").($_[2] or "").">".($_[1] or "")."\n"; + } else {return "<".($_[0] or "div").($_[2] or "")." />\n"; + } +} + +sub html_content { + return html_tag("html", html_tag( "head", html_tag( "title", shift ) . shift ) . html_tag( "body", shift ) ); +} + +sub soft_die { + print http_status(500,"text/html; charset=utf-8"); + print html_content("500","",shift); + exit; +} + +sub clean_input { + my $input = shift; + if ($input =~ m!%2F!) { soft_die( "Location/hax\r\n\r\n"; } + $input =~ s!%(..)!chr hex $1!ge; + $input =~ s!\+! !g; + return $input; +} + +my @request = get_request_info(); +my @get_params = split( "!", clean_input($request[2]) ); +# my @post_params +my $directive = shift(@get_params); +if ( "new" eq $directive ) { +# new session, new deck, new location +# if deck/location parent sessionID +# if location public/private +# returns id and key of new object +} elsif ( "shuffle" eq $directive ) { +# shuffle - deckID - full/current - deckKey +# sheffles all cards in deckID's locationID if deckKey matches +} elsif ( "move" eq $directive ) { +# move - cardID - current locationID - current locationKey - destination locationID +# changes ownership of cardID to destination locationID if cardID is owned by current locationID and the current locationKey matchs +} elsif ( "getLocations" eq $directive ) { +# getLocations - sessionID - sessionKey +# return all locationIDs associated with sessionID as long as sessionKey matches +} elsif ( "getCards" eq $directive ) { +# getCards - locationID - locationKey +# returns all cardIDs for locationID as long as its public or the locationKey matches +} elsif ( "getDecks" eq $directive ) { +# getDecks - sessionID - sessionKey +# returns all deckIDs associated with sessionID provided sessionKey matchs. +} else { + print http_status(200,"text/json"); + print '{"error":"No input or incorrect input", "input":"'.$directive.'!'.join("!",@get_params).'"}'; +} diff --git a/Database/base.sql b/Database/base.sql new file mode 100644 index 0000000..767c73a --- /dev/null +++ b/Database/base.sql @@ -0,0 +1,24 @@ +create tablespace deckard_space + OWNER deckard + LOCATION '\tmp\deckard'; +create database deckard WITH + OWNER=deckard + TABLESPACE=deckard_space; +create table sessions ( + sessionID UUID PRIMARY KEY, + sessionKey VARCHAR (256) NOT NULL, + last_update TIMESTAMP NOT NULL +); +create table locations ( + locationID UUID PRIMARY KEY, + sessionID UUID REFERENCES sessions(sessionID), + locationType text CHECK (locationType = 'deck' or 'hand' or 'discard'), + showPublic boolean NOT NULL +); +create table cards ( + cardID UUID PRIMARY KEY + sessionID UUID REFERENCES sessions(sessionID), + locationID UUID REFERENCES locations(locationID), + cardContent text NOT NULL, + position integer NOT NULL +); diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e4a0d9 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +## Deckard and company +This project is an exansion on my original idea with [Deckard](https://labs.murkfall.net/bluesaxman/deckard), with this project I aim to make decard a fully over the internet multiplayer experience. + +### Goals: + +* Implement database backend +* Implement API backend +* Session creation +* Deck upload and sanitization +* Multipul Mixed and Separate decks per session +* Multipul Players per session. +* Multipul Discard piles + +### Installation + +Not yet written + +### Basic Play instructions + +Not yet written + +### Original Deckard project + +[For developing new decks](https://labs.murkfall.net/bluesaxman/deckard) \ No newline at end of file diff --git a/UI/css.css b/UI/css.css new file mode 100644 index 0000000..0a7903c --- /dev/null +++ b/UI/css.css @@ -0,0 +1,126 @@ +*|* { + margin:0; + padding:0; +} + +body { + display: flex; + flex-direction: column; + justify-content:center; + align-items:center; +} + +#disc { + display:block; + width:80%; + min-height:60%; + text-align:center; +} + +#menu { + display:flex; + justify-content: space-around; + align-items: center; + width:100%; +} + +#display { + display: flex; + justify-content: space-around; + align-items: stretch; + height: 80vh; + width: 100%; +} + +#deck, #deckDisp { + display: flex; + justify-content: center; + align-items: center; +} + +#deck { + width: 50%; + max-width: 50%; +} + +#hand { + display: flex; + width: 50%; + max-width: 50%; + overflow: auto; + justify-content: left; + align-items: center; +} + +.library { + background: rgba(200,200,200,1); + text-align:left; + margin:5px 5px -15px 5px; + padding:5px 5px 20px 5px; + min-height:10%; + border:solid 1px rgba(140,140,140,1); + border-radius:10px 10px 0px 0px; +} + +.button { + display: inline-block; + background: rgba(150,150,150,0.7); + user-select: none; + margin:1px; + padding:2px; + border:solid 1px rgba(90,90,90,0.5); + border-radius:5px; + cursor:pointer; +} + +.button:hover { + background: rgba(140,140,140,1); + margin:0px; + padding:3px; + transition:0.2s; +} + +.dialog_back { + position:absolute; + display:flex; + justify-content:center; + align-items:center; + top:0; + left:0; + width:100%; + height:100%; + background: rgba(0,0,0,0.7); +} + +.dialog_window { + display:flex; + flex-direction:column; + background: rgba(255,255,255,1); + border-radius:5px; +} + +.dialog_title { + display: flex; + align-items: center; + justify-content: space-between; + background: rgba(0,0,0,0.3); + padding: 0px 0px 0px 5px; +} + +.dialog_content { + padding: 5px; +} + +.card { + height: 3in; + width: 2in; + display: inline-block; + border: 1px rgba(0,0,0,1) solid; + border-radius: 5px; + min-height: 3in; + min-width: 2in; + max-height:3in; + max-width:5in; + overflow: auto; + background: rgb(216, 206, 184); +} diff --git a/UI/index.html b/UI/index.html new file mode 100644 index 0000000..1102ce0 --- /dev/null +++ b/UI/index.html @@ -0,0 +1,107 @@ + + + Deckard + + + + +

Welcome to Deckard

+ + +