-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
import axios from "axios"; | ||
|
||
function getUrl() { | ||
let url = process.env.VUE_APP_BACKEND_URL + ":" + process.env.VUE_APP_BACKEND_PORT; | ||
console.log(url); | ||
return url; | ||
let url = process.env.VUE_APP_BACKEND_URL + ":" + process.env.VUE_APP_BACKEND_PORT; | ||
console.log(url); | ||
return url; | ||
} | ||
|
||
const axiosClient = axios.create({ | ||
baseURL: getUrl(), | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
baseURL: getUrl(), | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
|
||
export function sendDraft(id, territoryName) { | ||
return axiosClient.post("/api/games/" + id + "/turn/draft", { territory: territoryName }); | ||
export function sendDraft(id, player, territoryName) { | ||
const draftData = { | ||
requestingPlayer: player, | ||
territory: territoryName | ||
} | ||
return axiosClient.post("/api/games/" + id + "/turn/draft", draftData); | ||
} | ||
|
||
export function sendAttack(id, fromTerritory, toTerritory) { | ||
const attack_data = { | ||
from: fromTerritory, | ||
to: toTerritory, | ||
} | ||
return axiosClient.post("/api/games/" + id + "/turn/attack", attack_data); | ||
export function sendAttack(id, player, fromTerritory, toTerritory) { | ||
const attack_data = { | ||
requestingPlayer: player, | ||
from: fromTerritory, | ||
to: toTerritory, | ||
} | ||
return axiosClient.post("/api/games/" + id + "/turn/attack", attack_data); | ||
} | ||
|
||
export function sendMove(id, unitsToMove) { | ||
return axiosClient.post("/api/games/" + id + "/turn/move", { units: unitsToMove }) | ||
export function sendMove(id, player, unitsToMove) { | ||
const moveData = { | ||
requestingPlayer: player, | ||
units: unitsToMove | ||
} | ||
return axiosClient.post("/api/games/" + id + "/turn/move", moveData) | ||
} | ||
|
||
export { axiosClient } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters