Skip to content

Commit

Permalink
Merge pull request #1 from DubskySteam/dev
Browse files Browse the repository at this point in the history
v0.3
  • Loading branch information
DubskySteam authored Jul 12, 2023
2 parents 3713321 + 5437f44 commit 9781b30
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb


# Added by cargo

/target
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "ffxiv-raidcompletion"
version = "0.3.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
reqwest = {version = "0.11.18", features = ["json"]}
serde = {version = "1.0.166", features = ["derive"]}
tokio = { version = "1.29.1", features = ["full"]}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# FFXIV-RaidCompletion
Tracks a players dungeon, trial & raid achievements
##### A fast and lightweight tracker for dungeon, trial & raid achievements
##### Made & maintained in my free-time, therefore no guarantee for instant bug fixes, updates etc.
![](https://img.shields.io/badge/Dev%20Version-0.1-red?style=for-the-badge&logo=git)
![](https://img.shields.io/badge/Game%20Version-6.4-blue?style=for-the-badge&logo=)
## Features [WIP]
- Show progression of pve content
## Screenshots [WIP]
59 changes: 59 additions & 0 deletions src/fetch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use serde::Deserialize;

use crate::player::PlayerData;

#[derive(Deserialize, Debug)]
struct Player {
Character: Box<p_character>,
Achievements: Box<p_achievements>
}

#[derive(Deserialize, Debug)]
struct p_achievements {
List: Vec<ListElement>
}

#[derive(Deserialize, Debug)]
struct ListElement {
ID: i32
}

#[derive(Deserialize, Debug)]
struct ActiveClassJob {
UnlockedState: Box<UnlockedState>,
Level: i32
}

#[derive(Deserialize, Debug)]
struct UnlockedState {
Name: String
}

#[derive(Deserialize, Debug)]
struct p_character {
ActiveClassJob: Box<ActiveClassJob>,
DC: String,
Name: String,
Server: String,
Title: i32
}

pub async fn fetch_data(id: &str, P_DATA: &mut PlayerData) -> Result<(), Box<dyn std::error::Error>> {
println!("STARTING TO FETCH");
let p_data = reqwest::get("https://xivapi.com/character/".to_owned() + id + "?data=AC")
.await?
.json::<Player>()
.await?;

//println!("pdata:\n{:?}", p_data);
P_DATA.name = p_data.Character.Name;
P_DATA.server = p_data.Character.Server;
P_DATA.datacenter = p_data.Character.DC;
P_DATA.level = p_data.Character.ActiveClassJob.Level;
P_DATA.class = p_data.Character.ActiveClassJob.UnlockedState.Name;
for i in p_data.Achievements.List.iter() {
P_DATA.achievements.push(i.ID)
}

Ok(())
}
34 changes: 34 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(unused_imports)]

mod player;
mod fetch;
use player::PlayerData;

static P_ID: &str = "48486396";

#[tokio::main]
async fn main() {
//Initial player data
let mut P_DATA: PlayerData = PlayerData {
name: String::new(),
level: 0,
class: String::new(),
datacenter: String::new(),
server: String::new(),
achievements: Vec::new()
};

//fetch data from api and do provisional print
let _ = fetch::fetch_data(P_ID, &mut P_DATA).await;
println!("Char: {}\nLevel: {}\nClass: {}\nDC: {}\nServer: {}\nAchievements: {:?}",
P_DATA.name,
P_DATA.level,
P_DATA.class,
P_DATA.datacenter,
P_DATA.server,
P_DATA.achievements
);
}
8 changes: 8 additions & 0 deletions src/player.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub struct PlayerData {
pub name: String,
pub level: i32,
pub class: String,
pub datacenter: String,
pub server: String,
pub achievements: Vec<i32>
}

0 comments on commit 9781b30

Please sign in to comment.