Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1e2258c
commit message
MirunaLM Aug 22, 2019
ec0cfa2
cicd-integration: Jenkinsfile created with simple steps of building, …
Aug 22, 2019
6cacfb1
cicd-integration: deploy.sh script created, have to implement still.
Aug 22, 2019
82ce0f9
cicd-integration: Simple deploy script for testing the Jenkins pipeline.
Aug 22, 2019
291eca2
cicd-integration: Moved Jenkinsfile to the root of project.
Aug 22, 2019
f1679de
cicd-integration: Removing colon after key to attempt fix declarative…
Aug 22, 2019
de45c83
cicd-integration: Added missing junit call and fixed the 'always' dec…
Aug 22, 2019
e4d72e7
Merge remote-tracking branch 'origin/master' into cicd-integration
Aug 22, 2019
2bc31d0
cicd-integration: Using the latest image of maven.
Aug 22, 2019
2d3bc33
cicd-integration: Debug maven flag.
Aug 22, 2019
eebb0d4
cicd-integration: bumping up Maven Compiler plugin version.
Aug 22, 2019
e99de8c
cicd-integration: using different JDK version for maven.
Aug 22, 2019
a671654
cicd-integration: More general version of Maven with correct JDK vers…
Aug 22, 2019
2cb2fb3
cicd-integration: changed deploy permissions.
Aug 22, 2019
9566226
cicd-integration: deploy script updated.
Aug 23, 2019
18d4f6b
cicd-integration: Deploy scripts for different environmnets. DEV and …
Aug 23, 2019
94033f6
Merge branch 'master' into cicd-integration
Aug 23, 2019
fde8e97
Update issue templates
Aug 23, 2019
77a6e2e
Merge pull request #14 from javaplebes/happysad--patch-1
Aug 23, 2019
2379c5d
lexer
MirunaLM Aug 23, 2019
083b7f4
Merge pull request #10 from javaplebes/cicd-integration
Aug 23, 2019
679e6b4
Lexer
MirunaLM Aug 23, 2019
049bd59
lexer
MirunaLM Aug 23, 2019
d19afc5
Update Lexer.java
MirunaLM Aug 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/request-form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Request Form
about: Request access for the services keeping this project alive.
title: "[REQUEST]: Server Access"
labels: Request
assignees: happysad-

---

## Which service do you require access for?
- [ ] Jenkins CI / Pipelines
- [ ] DEV server access
- [ ] PREPROD server access
- [ ] PROD server access
- [ ] DEV database
- [ ] PROD database

## Description
Describe why you need access to the selected service, please be as descriptive as possible.
42 changes: 29 additions & 13 deletions jenkins/scripts/deploy-dev.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
#!/usr/bin/env sh

#
# Will change this so it copies the latest build created by Jenkins
# so the DEV server won't have to rebuild an already built project.
#

ORG_PATH="~/JavaPlebes"
get_xpath_value() {
xml=$1
path=$2
if [ -f "${xml}" ]; then
value=$( xpath "${xml} ${path}" 2>/dev/null | perl -pe 's/^.+?\>//; s/\<.+?$//;' )
echo "${value}"
else
echo "Invalid xml file: ${xml}!"
exit 1
fi
}

ORG_PATH="${HOME}/JavaPlebes"
PROJ_DIR="/TextAdventure"
GIT_URL="git@github.com:javaplebes/TextAdventure.git"

if [ ! -d "$ORG_PATH" ]; then
if [ ! -d "${ORG_PATH}" ]; then
echo "Organisation path does not exist. Creating..."
mkdir ORG_PATH
mkdir "${ORG_PATH}"
fi

cd $ORG_PATH
cd "${ORG_PATH}" || echo "Unable to change directory to: ${ORG_PATH}. Exiting..."; exit 1

if [ -! -d "$PROJ_DIR" ]; then
if [ ! -d "${PROJ_DIR}" ]; then
echo "Project directory does not exist. Cloning latest from GitHub..."
git clone $GIT_URL $PROJ_DIR
git clone "${GIT_URL} ${PROJ_DIR}"
fi

cd $PROJ_DIR
cd "${PROJ_DIR}" || echo "Unable to change directory to: ${PROJ_DIR}. Exiting..."; exit 1

echo "Pulling the latest master branch..."
git pull origin master

echo "Deploy not yet implemented!"
mvn compile
mvn test
mvn package

# Running of JAR on server currently disabled as not sure how to present the 'frontend' of the game.
ARTIFACT_ID=$(get_xpath_value "/pom.xml" "project/artifactId")
VERSION=$(get_xpath_value "/pom.xml" "project/version")
#java -jar "/target/${ARTIFACT_ID}-${VERSION}.jar"

echo "Deployed: ${ARTIFACT_ID}-${VERSION}"
45 changes: 45 additions & 0 deletions jenkins/scripts/deploy-preprod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env sh

get_xpath_value() {
xml=$1
path=$2
if [ -f "${xml}" ]; then
value=$( xpath "${xml} ${path}" 2>/dev/null | perl -pe 's/^.+?\>//; s/\<.+?$//;' )
echo "${value}"
else
echo "Invalid xml file: ${xml}!"
exit 1
fi
}

ORG_PATH="${HOME}/JavaPlebes"
PROJ_DIR="/TextAdventure"
GIT_URL="git@github.com:javaplebes/TextAdventure.git"

if [ ! -d "${ORG_PATH}" ]; then
echo "Organisation path does not exist. Creating..."
mkdir "${ORG_PATH}"
fi

cd "${ORG_PATH}" || echo "Unable to change directory to: ${ORG_PATH}. Exiting..."; exit 1

if [ ! -d "${PROJ_DIR}" ]; then
echo "Project directory does not exist. Cloning latest from GitHub..."
git clone "${GIT_URL} ${PROJ_DIR}"
fi

cd "${PROJ_DIR}" || echo "Unable to change directory to: ${PROJ_DIR}. Exiting..."; exit 1

echo "Pulling the latest master branch..."
git pull origin master

mvn compile
mvn test
mvn package

# Running of JAR on server currently disabled as not sure how to present the 'frontend' of the game.
ARTIFACT_ID=$(get_xpath_value "/pom.xml" "project/artifactId")
VERSION=$(get_xpath_value "/pom.xml" "project/version")
#java -jar "/target/${ARTIFACT_ID}-${VERSION}.jar"

echo "Deployed: ${ARTIFACT_ID}-${VERSION}"
43 changes: 43 additions & 0 deletions jenkins/scripts/deploy-prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env sh

get_xpath_value() {
xml=$1
path=$2
if [ -f "${xml}" ]; then
value=$( xpath "${xml} ${path}" 2>/dev/null | perl -pe 's/^.+?\>//; s/\<.+?$//;' )
echo "${value}"
else
echo "Invalid xml file: ${xml}!"
exit 1
fi
}

ORG_PATH="${HOME}/${PROD_ORG_PATH}"
PROJ_DIR="${PROD_PROJ_DIR}"
XML_PATH="${PROD_XML_PATH}"

if [ ! -d "${ORG_PATH}" ]; then
echo "Organisation path does not exist. Exiting..."
fi

cd "${ORG_PATH}" || echo "Unable to change directory to: ${ORG_PATH}. Exiting..."; exit 1

if [ ! -d "${PROJ_DIR}" ]; then
echo "Project directory does not exist. Exiting..."; exit 1
fi

cd "${PROJ_DIR}" || echo "Unable to change directory to: ${PROJ_DIR}. Exiting..."; exit 1

echo "Pulling the latest master branch..."
git pull origin master

mvn compile
mvn test
mvn package

# Running of JAR on server currently disabled as not sure how to present the 'frontend' of the game.
ARTIFACT_ID=$(get_xpath_value "${XML_PATH}" "project/artifactId")
VERSION=$(get_xpath_value "${XML_PATH}" "project/version")
#java -jar "${ARTIFACT_ID}-${VERSION}.jar"

echo "Deployed: ${ARTIFACT_ID}-${VERSION}"
39 changes: 34 additions & 5 deletions jenkins/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
#!/usr/bin/env sh

# Todo: Write a simple deploy script
echo "Deploy not implemented yet!"
deploy_to_env() {
if [ -z "$1" ] || [ "$1" = "DEV" ]; then
echo "Deploying to DEV environment."
ssh "${PROJ_USER}@${DEV_SERVER}" "bash -s" < deploy-dev.sh
elif [ "$1" = "PREPROD" ]; then
echo "Deploying to PREPROD environment."
ssh "${PROJ_USER}@${PREPROD_SERVER}" "bash -s" < deploy-preprod.sh
elif [ "$1" = "PROD" ]; then
echo "Deploying to PROD environment."
ssh "${PROJ_USER}@${PROD_SERVER}" "bash -s" < deploy-prod.sh
else
echo "Unknown environment."
return 1
fi
}

echo "Running the deployment script on DEV environment..."
echo "Secrets have not yet been added."
#ssh jenkins-ci@shard-server-lon01 'bash -s' < deploy-dev.sh
check_environment() {
if [ -z "${PROJ_USER}" ] \
|| [ -z "${DEV_SERVER}" ] \
|| [ -z "${PREPROD_SERVER}" ] \
|| [ -z "${PROD_SERVER}" ]; then
return 1
fi
}

if ! check_environment ; then
echo "Environment is not correctly set up. Exiting..."
exit 1
else
if ! deploy_to_env "$@" ; then
echo "Something went wrong during deployment. Exiting..."
else
echo "Successfully deployed to server. [$1]"
fi
fi
62 changes: 37 additions & 25 deletions src/main/java/com/textadventure/Lexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,56 @@
public class Lexer {

public enum TokenType {
MOVEMENT(" w | a | s | d "), WALK("walk"), RUN("run"), DIRECTION("North|South|East|West"),
WHITESPACE("[ \t\f\r\n]+");
WALK("walk"), RUN("run"), DIRECTION("North|South|East|West");
public final String pattern;

private TokenType(String pattern) {
TokenType(String pattern) {
this.pattern = pattern;
}
}

public static ArrayList<Token> lex(String input) {
// The tokens to return
ArrayList<Token> tokens = new ArrayList<>();
ArrayList<Token> tokens = new ArrayList<Token>();

// Lexer logic begins here
StringBuffer tokenPatternsBuffer = new StringBuffer();
StringBuilder tokenPatternsBuilder = new StringBuilder();
for (TokenType tokenType : TokenType.values())
tokenPatternsBuilder.append(String.format("|(?<%s>%s)", tokenType.name(), tokenType.pattern));
Pattern tokenPatterns = Pattern.compile(tokenPatternsBuilder.substring(1));

for (String word : input.split(" ")) {
// Begin matching tokens
Matcher matcher = tokenPatterns.matcher(word);
while (matcher.find()) {
if (matcher.group(TokenType.WALK.name()) != null) {
tokens.add(new Token(TokenType.WALK, matcher.group(TokenType.WALK.name())));
continue;
} else if (matcher.group(TokenType.RUN.name()) != null) {
tokens.add(new Token(TokenType.RUN, matcher.group(TokenType.RUN.name())));
continue;
} else if (matcher.group(TokenType.DIRECTION.name()) != null) {
tokens.add(new Token(TokenType.DIRECTION, matcher.group(TokenType.DIRECTION.name())));
}
}
tokenPatternsBuffer.append(String.format("|(?<%s>%s)", tokenType.name(), tokenType.pattern));
Pattern tokenPatterns = Pattern.compile(tokenPatternsBuffer.substring(1));

// Begin matching tokens
Matcher matcher = tokenPatterns.matcher(input);
while (matcher.find()) {
if (matcher.group(TokenType.MOVEMENT.name()) != null) {
tokens.add(new Token(TokenType.MOVEMENT, matcher.group(TokenType.MOVEMENT.name())));
continue;
} else if (matcher.group(TokenType.WALK.name()) != null) {
tokens.add(new Token(TokenType.WALK, matcher.group(TokenType.WALK.name())));
continue;
} else if (matcher.group(TokenType.RUN.name()) != null) {
tokens.add(new Token(TokenType.RUN, matcher.group(TokenType.RUN.name())));
continue;
} else if (matcher.group(TokenType.DIRECTION.name()) != null) {
tokens.add(new Token(TokenType.DIRECTION, matcher.group(TokenType.DIRECTION.name())));
continue;
} else if (matcher.group(TokenType.WHITESPACE.name()) != null)
continue;

for(String word: input.split(" ")) {
// Begin matching tokens
Matcher matcher = tokenPatterns.matcher(word);
while (matcher.find()) {
if (matcher.group(TokenType.WALK.name()) != null) {
tokens.add(new Token(TokenType.WALK, matcher.group(TokenType.WALK.name())));
continue;
} else if (matcher.group(TokenType.RUN.name()) != null) {
tokens.add(new Token(TokenType.RUN, matcher.group(TokenType.RUN.name())));
continue;
} else if (matcher.group(TokenType.DIRECTION.name()) != null) {
tokens.add(new Token(TokenType.DIRECTION, matcher.group(TokenType.DIRECTION.name())));
}
}
}

return tokens;
}
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/textadventure/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
public class Main {

public static void main(String[] args) {
<<<<<<< HEAD
log.info("Hi there! Let's rock this");
String input = " w walk s North";

ArrayList<Token> tokens = Lexer.lex(input);
for (Token token : tokens)
log.info(token.toString());
=======
System.out.println("Hi there! Let's rock this");
>>>>>>> 2379c5d31875271667c3eed689ccf1d115ff8d03
}
}
Loading