derniere version

Daniel-alias-la-puissance
Melro Serdoura Daniel ago%!(EXTRA string=1 year)
parent 2c2507cf79
commit 3bfec8032f
  1. 3
      .gitmodules
  2. 3
      .vscode/settings.json
  3. BIN
      assets/KRITA/ANTIMATTER.kra
  4. BIN
      assets/KRITA/SKAMKRAFTLOGO.kra
  5. BIN
      assets/KRITA/SKAMKRAFTLOGO1.kra
  6. BIN
      assets/KRITA/agent.kra
  7. BIN
      assets/KRITA/asteroid1.kra
  8. BIN
      assets/KRITA/asteroid2.kra
  9. BIN
      assets/KRITA/asteroid3.kra
  10. BIN
      assets/KRITA/asteroid4.kra
  11. BIN
      assets/KRITA/background.kra
  12. BIN
      assets/KRITA/backgroundfinal.kra
  13. BIN
      assets/KRITA/blackhole.kra
  14. BIN
      assets/KRITA/bluesystem.kra
  15. BIN
      assets/KRITA/greensystem.kra
  16. BIN
      assets/KRITA/jumpgate.kra
  17. BIN
      assets/KRITA/medkit.kra
  18. BIN
      assets/KRITA/pinksystem.kra
  19. BIN
      assets/KRITA/planetproto.kra
  20. BIN
      assets/KRITA/plastic.kra
  21. BIN
      assets/KRITA/procurement.kra
  22. BIN
      assets/KRITA/redsystem.kra
  23. BIN
      assets/KRITA/shuttle.kra
  24. BIN
      assets/KRITA/spaceship.kra
  25. BIN
      assets/KRITA/spaceshiporbits.kra
  26. BIN
      assets/KRITA/transportation.kra
  27. BIN
      assets/KRITA/whitehole.kra
  28. BIN
      assets/KRITA/yellowsystem.kra
  29. BIN
      assets/img/background.jpg
  30. BIN
      assets/img/background.png
  31. BIN
      assets/logo/elephant.png
  32. BIN
      assets/planets/asteroid1.png
  33. BIN
      assets/planets/asteroid2.png
  34. BIN
      assets/planets/asteroid3.png
  35. BIN
      assets/planets/asteroid4.png
  36. BIN
      assets/planets/blackhole.png
  37. BIN
      assets/planets/jumpgate.png
  38. BIN
      assets/planets/whitehole.png
  39. BIN
      assets/spaceships/blueprint.png
  40. BIN
      assets/spaceships/vaisseau.avif
  41. BIN
      assets/systems/bluesystem.png
  42. BIN
      assets/systems/galaxie1.png
  43. BIN
      assets/systems/greensystem.png
  44. BIN
      assets/systems/pinksystem.png
  45. BIN
      assets/systems/redsystem.png
  46. BIN
      assets/systems/yellowsystem.png
  47. 2
      css/animation.css
  48. 11
      css/style.css
  49. 2
      html/template.html
  50. 13
      html/templates/ship/ship.html
  51. 9
      html/templates/ship/ship_modal.html
  52. 2
      index.html
  53. 1
      js/controllers/home.js
  54. 80
      js/controllers/login.js
  55. 44
      js/controllers/menu_mod.js
  56. 65
      js/controllers/reg.js
  57. 6
      js/controllers/systems.js
  58. 17
      js/skama_code/api/agent.js
  59. 2
      js/skama_code/api/config.js
  60. 0
      js/skama_code/api/ntm.js
  61. 76
      js/skama_code/api/ship.js
  62. 56
      js/skama_code/api/system.js
  63. 5
      js/skama_code/commun/my.js
  64. 22
      js/skama_code/ui/templeting_engine.js

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "js/skama_code"]
path = js/skama_code
url = https://github.com/anulax1225/skama_code

@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 287 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 545 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

@ -2,7 +2,7 @@
.ext-modal[open] {
animation: myFadeIn 2.0s ease normal;
animation: myFadeIn 0.5s ease normal;
}
@keyframes myFadeIn{

@ -15,7 +15,7 @@
}
body {
background-image: url("/assets/img/background.jpg");
background-image: url("/assets/img/background.png");
font-family: 'M42';
font-size: 7px;
margin: 0px;
@ -84,11 +84,12 @@ footer {
/*nav bar*/
.nav-nav {
--nav-img-width: 100px;
--nav-img-width: 75px;
background-color: var(--second-back-color);
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 10px 10px 10px;
}
.nav-nav .nav-brand {
@ -102,9 +103,9 @@ footer {
}
.nav-nav .nav-links {
--links-color: rgb(0,0,0);
--links-backcolor: rgb(255, 123, 71);
--links-border-color: rgb(255, 173, 118);
--links-color: rgb(255, 255, 255);
--links-backcolor: rgb(0, 0, 0);
--links-border-color: rgb(255, 255, 255);
height: 70%;
display: flex;
justify-content: space-between;

@ -1,7 +1,7 @@
<!-- Copyright © 2023 Entreprise SkamKraft -->
<nav class="nav-nav">
<div class="nav-brand">
<img src="assets/logo/logoblancnotext.png" />
<img src="assets/logo/elephant.png" />
</div>
<div class="stats"></div>
<ul class="nav-links">

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ship</title>
</head>
<body>
<div class="ships">
</div>
</body>
</html>

@ -1,9 +0,0 @@
<!-- Copyright © 2023 Entreprise SkamKraft -->
<div class="my-modal">
<div class="infos">
</div>
<div>
<button class="btn btn-val btn-close">Close</button>
</div>
</div>

@ -5,8 +5,6 @@
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/ui.css">
<link rel="stylesheet" href="css/animation.css">
<link rel="stylesheet" href="css/ships.css">
<script src="js/lib/fabric.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="module" src="js/index.js" defer></script>

@ -1,6 +1,7 @@
import menu_mod from "./menu_mod.js";
export default function home(temp_engine) {
console.log("test");
temp_engine.after_render(menu_mod);
temp_engine.render("templates/home.html");
}

@ -5,53 +5,47 @@ import home from "./home.js";
import menu_mod from "./menu_mod.js";
export default function login(temp_engine) {
let auth = new Auth(true);
let modal = new Modal("login-modal", temp_engine);
function render_login() {
temp_engine.render(`templates/auth/login.html`);
}
modal.add_class("ext-modal");
temp_engine.after_render((temp_engine) => {
modal.load("templates/auth/login_modal.html");
menu_mod(temp_engine);
temp_engine.add_event("#ok", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#forget_login", "click", () => {
My.agent = null;
auth.unload_token();
modal.close();
render_login();
let auth = new Auth(true);
let modal = new Modal("login-modal", temp_engine);
modal.add_class("ext-modal");
temp_engine.after_render((temp_engine) => {
modal.load("templates/auth/login_modal.html")
menu_mod(temp_engine);
temp_engine.add_event("#ok", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#forget_login", "click", () => {
My.agent = null;
auth.unload_token();
modal.close();
render_login();
});
temp_engine.add_event("#val", "click", () => {
let token = $("#in-token").val();
auth.login(token);
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-token").val("");
});
});
temp_engine.add_event("#val", "click", () => {
let token = $("#in-token").val();
auth.login(token);
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-token").val("");
});
});
render_login();
temp_engine.render(`templates/auth/login.html`);
auth
.done((agent) => {
modal.show();
My.agent = agent;
})
.fail((errs) => {
$(".errors").html("");
errs.forEach((err) => {
$(".errors").append(`
auth.done((agent) => {
modal.show();
My.agent = agent;
}).fail((errs) => {
$(".errors").html("");
errs.forEach(err => {
$(".errors").append(`
<p>${err}</p>
`);
});
});
});
auth.relog();
}
auth.relog();
}

@ -3,35 +3,31 @@ import login from "./login.js";
import reg from "./reg.js";
import home from "./home.js";
import { systems } from "./systems.js";
import Ship from "./ships.js";
function init_menu(temp_engine) {
temp_engine.add_event("#reg-link", "click", () => {
reg(temp_engine);
});
temp_engine.add_event("#login-link", "click", () => {
login(temp_engine);
});
temp_engine.add_event("#systems-link", "click", () => {
systems(temp_engine);
});
temp_engine.add_event(".nav-brand", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#ships-link", "click", () => {
Ship(temp_engine);
});
temp_engine.add_event("#reg-link", "click", () => {
reg(temp_engine);
});
temp_engine.add_event("#login-link", "click", () => {
login(temp_engine);
});
temp_engine.add_event("#systems-link", "click", () => {
systems(temp_engine);
});
temp_engine.add_event(".nav-brand", "click", () => {
home(temp_engine);
});
}
function loged_links() {
$(".nav-links").prepend(`
$(".nav-links").prepend(`
<li class="nav-link smooth" id="contracts-link">Contracts</li>
<li class="nav-link smooth" id="ships-link">Ships</li>
`);
}
function show_stats() {
$(".stats").html(`
$(".stats").html(`
<p>Agent name : ${My.agent.name}</p>
<p>Credits : ${My.agent.credits}</p>
<p>Ships : ${My.agent.ships_cpt}</p>
@ -41,9 +37,9 @@ function show_stats() {
}
export default function menu_mod(temp_engine) {
init_menu(temp_engine);
if (My.agent) {
show_stats();
loged_links();
}
}
init_menu(temp_engine);
if(My.agent) {
show_stats();
loged_links();
}
}

@ -9,43 +9,40 @@ export default function reg(temp_engine) {
let auth = new Auth(true);
let modal = new Modal("reg-modal", temp_engine);
function render_reg() {
temp_engine.render(`templates/auth/reg.html`);
modal.load("templates/auth/reg_modal.html")
}
modal.add_class("ext-modal");
temp_engine.after_render(menu_mod);
render_reg();
temp_engine.add_event("#ok", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#forget_reg", "click", () => {
My.agent = null;
auth.unload_token();
modal.close();
render_reg();
});
temp_engine.add_event("#val", "click", () => {
if (!active) {
active = true;
let name = $("#in-name").val();
let faction = $("#in-faction").val();
auth.register({
name: name,
faction: faction
});
}
temp_engine.after_render((temp_engine) => {
menu_mod(temp_engine);
modal.load("templates/auth/reg_modal.html");
temp_engine.add_event("#ok", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#forget_reg", "click", () => {
My.agent = null;
auth.unload_token();
modal.close();
render_reg();
});
temp_engine.add_event("#val", "click", () => {
if (!active) {
active = true;
let name = $("#in-name").val();
let faction = $("#in-faction").val();
auth.register({
name: name,
faction: faction
});
}
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-name").val("");
$("#in-faction").val("");
});
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-name").val("");
$("#in-faction").val("");
});
temp_engine.render(`templates/auth/reg.html`);
auth.done((agent) => {
$(".show-token").text(agent.token);

@ -26,12 +26,12 @@ function draw_system(system) {
offsetY: 0,
});
fabric.Image.fromURL('/assets/systems/galaxie1.png', function(img_planet) {
fabric.Image.fromURL('/assets/systems/bluesystem.png', function(img_planet) {
img_planet.set({
selectable: false,
scaleX: 0.05,
scaleY: 0.05,
scaleX: 0.20,
scaleY: 0.20,
shadow: shadow,
left: system.position.x/offset.x + w/2,
top: system.position.y/offset.y+ h/2,

@ -4,6 +4,8 @@ import { SpaceTraders } from "./config.js"
export class My {
static agent = null;
static temp_engine = null;
static canvas_renderer = null;
}
export class Agent {
@ -23,6 +25,11 @@ export class Agent {
}
export class AgentBuilder {
constructor(end = false) {
this.stopped = false;
this.end = end;
}
static create(symbol, faction, callback, error_handler) {
const url = `${SpaceTraders.host}/register`;
$.ajax({
@ -94,22 +101,22 @@ export class AgentBuilder {
});
}
static list_all(callback, end = false) {
static list_all(callback) {
this.list(20, 1, (agents, meta) => {
let maxPage = meta.total / 20;
this.#r_listing(2, maxPage, agents, callback, end);
this.#r_listing(2, maxPage, agents, callback);
});
}
static #r_listing(page, maxPage, agents, callback, end) {
static #r_listing(page, maxPage, agents, callback) {
if (page < maxPage) {
this.list(20, page++,() => {
setTimeout(() => {
if (!end) {
if (!this.end) {
callback(agents);
agents = [];
}
this.#r_listing(page++, maxPage, agents, callback, end);
if (!this.stopped) this.#r_listing(page++, maxPage, agents, callback, end);
}, 1000);
}, agents);
} else {

@ -3,5 +3,5 @@
export const SpaceTraders = {
host: "https://api.spacetraders.io/v2",
limit_max: 20,
timing: 1000,
}

@ -101,7 +101,7 @@ export class Ship {
}
orbit(callback, error_handler) {
if (this.nav.status == "ORBIT")
if (this.nav.status == "IN_ORBIT")
return error_handler("Ship already in orbit.");
const url = `${SpaceTraders.host}/my/ships/${this.symbol}/orbit`;
@ -121,76 +121,4 @@ export class Ship {
},
});
}
dock(callback, error_handler) {
if (this.nav.status == "DOCKED")
return error_handler("Ship already docked");
const url = `${SpaceTraders.host}/my/ships/${this.symbol}/dock`;
$.ajax({
url: url,
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${My.agent.token}`,
},
success: (response) => {
callback(response.data);
},
error: (err) => {
error_handler(err);
},
});
}
navigate(waypoint, callback, error_handler) {
if (this.nav.status != "ORBIT")
return error_handler("Ship must be in orbit.");
const url = `${SpaceTraders.host}/my/ships/${this.symbol}/navigate`;
$.ajax({
url: url,
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${My.agent.token}`,
},
processData: false,
data: `{\n "waypointSymbol": "${waypoint}"\n}`,
success: (response) => {
callback(response);
},
error: (err) => {
error_handler(err);
},
});
}
refuel(callback, error_handler) {
if (this.nav.status != "ORBIT")
return error_handler("Ship must be in orbit.");
const url = `${SpaceTraders.host}/my/ships/${this.symbol}/refuel`;
$.ajax({
url: url,
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer 123",
},
processData: false,
data: '{\n "units": "100",\n "fromCargo": false\n}',
success: (response) => {
callback(response);
},
error: (err) => {
error_handler(err);
},
});
}
}
}

@ -12,9 +12,15 @@ export class System {
this.type = data.type;
this.position = new Position(data.x, data.y);
this.factions = data.factions;
this.stopped = false;
this.end = false;
}
get(name, callback, error_handler) {
when_end() {
this.end = true;
}
get_planet(name, callback, error_handler) {
const url = `${SpaceTraders.host}/systems/${this.name}/waypoints/${name}`;
$.ajax({
url: url,
@ -29,7 +35,7 @@ export class System {
});
}
list(limit, page, callback, planets = []) {
list_planets(limit, page, callback, planets = []) {
const url = `${SpaceTraders.host}/systems/${this.name}/waypoints`
$.ajax({
url: url,
@ -47,23 +53,27 @@ export class System {
});
}
list_all(callback, end = false) {
this.list(20, 1, (planets, meta) => {
stop() {
this.stopped = true;
}
list_all_planets(callback, end = false) {
this.list_planets(20, 1, (planets, meta) => {
let maxPage = meta.total / 20;
this.#r_listing(2, maxPage, planets, callback, end);
});
}
#r_listing(page, maxPage, planets, callback, end) {
#r_listing(page, maxPage, planets, callback) {
if (page < maxPage) {
this.list(20, page++, () => {
this.list_planets(20, page++, () => {
setTimeout(() => {
if (!end) {
callback(planets);
planets = [];
}
this.#r_listing(page++, maxPage, planets, callback, end);
}, 1000);
if (!this.stopped) this.#r_listing(page++, maxPage, planets, callback, end);
}, SpaceTraders.timing);
}, planets);
} else {
callback(planets);
@ -72,6 +82,13 @@ export class System {
}
export class SystemBuilder {
constructor(end = false) {
this.stopped = false;
this.end = end;
this.page = 1;
}
static parse_system_name(name) {
return name.split("-").slice(-1, 2).join("-");
}
@ -109,24 +126,27 @@ export class SystemBuilder {
});
}
static list_all(callback, end = false) {
this.list(20, 1, (systems, meta) => {
let maxPage = meta.total / 20;
this.#r_listing(2, maxPage, systems, callback, end);
stop() {
this.stopped = true;
}
list_all(callback) {
SystemBuilder.list(20, this.page, (systems, meta) => {
this.max_page = meta.total / 20;
this.#r_listing(systems, callback);
});
}
static #r_listing(page, maxPage, systems, callback, end) {
#r_listing(systems, callback) {
if (page < maxPage) {
this.list(20, page++, () => {
SystemBuilder.list(20, this.page++, () => {
setTimeout(() => {
if (!end) {
console.log(systems);
if (!this.end) {
callback(systems);
systems = [];
}
this.#r_listing(page++, maxPage, systems, callback, end);
}, 1000);
if (!this.stopped) this.#r_listing(page++, maxPage, systems, callback);
}, SpaceTraders.timing);
}, systems);
} else {
callback(systems);

@ -0,0 +1,5 @@
export class My {
static agent = null;
static temp_engine = null;
static canvas_renderer = null;
}

@ -1,18 +1,17 @@
// Copyright © 2023 Entreprise SkamKraft
"use strict";
'use strict';
export class TemplateEngine {
constructor(path) {
this.templatePath = path;
}
render(template) {
this.get_template((reponse) => {
$("body").html(reponse);
$('body').html(reponse);
this.get_template((reponse) => {
$("#block-content").html(reponse);
if (this.after_render_callback)
this.#flush_events().after_render_callback(this);
}, template);
if (this.after_render_callback) this.#flush_events().after_render_callback(this);
}, template)
});
}
@ -23,16 +22,13 @@ export class TemplateEngine {
}
get_template(callback, template = "") {
let url =
template === ""
? `${this.templatePath}/template.html`
: `${this.templatePath}/${template}`;
$.ajax(url, {
let url = template === "" ? `${this.templatePath}/template.html`: `${this.templatePath}/${template}`;
$.ajax(url,{
method: "GET",
success: callback,
error: (err) => {
console.log(err);
},
}
});
}
@ -46,6 +42,6 @@ export class TemplateEngine {
}
after_render(callback) {
this.after_render_callback = callback;
this.after_render_callback = callback;
}
}

Loading…
Cancel
Save